9 "git.arvados.org/arvados.git/sdk/go/arvados"
12 type pythonPCA struct{}
14 func (cmd *pythonPCA) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
18 fmt.Fprintf(stderr, "%s\n", err)
21 flags := flag.NewFlagSet("", flag.ContinueOnError)
22 flags.SetOutput(stderr)
23 projectUUID := flags.String("project", "", "project `UUID` for output data")
24 inputFilename := flags.String("i", "-", "input `file`")
25 priority := flags.Int("priority", 500, "container request priority")
26 err = flags.Parse(args)
27 if err == flag.ErrHelp {
30 } else if err != nil {
34 runner := arvadosContainerRunner{
35 Name: "lightning pca",
36 Client: arvados.NewClientFromEnv(),
37 ProjectUUID: *projectUUID,
42 err = runner.TranslatePaths(inputFilename)
46 runner.Prog = "python3"
47 runner.Args = []string{"-c", `import sys
49 from sklearn.decomposition import PCA
50 scipy.save(sys.argv[2], PCA(n_components=4).fit_transform(scipy.load(sys.argv[1])))`, *inputFilename, "/mnt/output/pca.npy"}
52 output, err = runner.Run()
56 fmt.Fprintln(stdout, output+"/pca.npy")