1 // Copyright (C) The Lightning Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
15 "git.arvados.org/arvados.git/sdk/go/arvados"
18 type manhattanPlot struct{}
20 //go:embed manhattan.py
21 var manhattanPy string
23 func (cmd *manhattanPlot) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
27 fmt.Fprintf(stderr, "%s\n", err)
30 flags := flag.NewFlagSet("", flag.ContinueOnError)
31 flags.SetOutput(stderr)
32 projectUUID := flags.String("project", "", "project `UUID` for output data")
33 inputDirectory := flags.String("i", "-", "input `directory` (output of slice-numpy -single-onehot)")
34 outputFilename := flags.String("o", "", "output `filename` (e.g., './plot.png')")
35 priority := flags.Int("priority", 500, "container request priority")
36 runlocal := flags.Bool("local", false, "run on local host (default: run in an arvados container)")
37 err = flags.Parse(args)
38 if err == flag.ErrHelp {
41 } else if err != nil {
43 } else if flags.NArg() > 0 {
44 err = fmt.Errorf("errant command line arguments after parsed flags: %v", flags.Args())
48 runner := arvadosContainerRunner{
49 Name: "lightning manhattan",
50 Client: arvados.NewClientFromEnv(),
51 ProjectUUID: *projectUUID,
55 Mounts: map[string]map[string]interface{}{
56 "/manhattan.py": map[string]interface{}{
58 "content": manhattanPy,
63 err = runner.TranslatePaths(inputDirectory)
67 *outputFilename = "/mnt/output/plot.png"
74 if *outputFilename == "" {
75 fmt.Fprintln(stderr, "error: must specify -o filename.png in local mode (or try -help)")
78 cmd := exec.Command("python3", append([]string{"-"}, args...)...)
79 cmd.Stdin = strings.NewReader(manhattanPy)
88 runner.Prog = "python3"
89 runner.Args = append([]string{"/manhattan.py"}, args...)
91 output, err = runner.Run()
95 fmt.Fprintln(stdout, output+"/plot.png")