Skip to content

Commit

Permalink
bug: allow multiple run command and use bash -c (#720)
Browse files Browse the repository at this point in the history
fix run

Signed-off-by: Jinjing.Zhou <allenzhou@tensorchord.ai>
  • Loading branch information
VoVAllen committed Aug 3, 2022
1 parent da8feb7 commit f22b283
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/lang/ir/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package ir

const (
osDefault = "ubuntu20.04"
languageDefault = "python"
languageDefault = "python3"
pypiIndexModeAuto = "auto"

// used inside the container
Expand Down
2 changes: 1 addition & 1 deletion pkg/lang/ir/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func RStudioServer() error {

func Run(commands []string) error {
// TODO(gaocegege): Support order-based exec.
DefaultGraph.Exec = commands
DefaultGraph.Exec = append(DefaultGraph.Exec, commands...)
return nil
}

Expand Down
7 changes: 4 additions & 3 deletions pkg/lang/ir/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ func (g Graph) compileRun(root llb.State) llb.State {
return root
}
root = root.AddEnv("PATH", "$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/conda/bin:/usr/local/julia/bin:/opt/conda/envs/envd/bin")
logrus.Debugf("compile run: %s", strings.Join(g.Exec, " "))
if len(g.Exec) == 1 {
return root.Run(llb.Shlex(g.Exec[0])).Root()
return root.Run(llb.Shlex(fmt.Sprintf("bash -c \"%s\"", g.Exec[0]))).Root()
}

run := root.Run(llb.Shlex(g.Exec[0]))
run := root.Run(llb.Shlex(fmt.Sprintf("bash -c \"%s\"", g.Exec[0])))
for _, c := range g.Exec[1:] {
run = run.Run(llb.Shlex(c))
run = run.Run(llb.Shlex(fmt.Sprintf("bash -c \"%s\"", c)))
}
return run.Root()
}
Expand Down

0 comments on commit f22b283

Please sign in to comment.