Skip to content

Commit

Permalink
fix: remove unnecessary if statement (#773)
Browse files Browse the repository at this point in the history
Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>

Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
  • Loading branch information
hezhizhen committed Aug 14, 2022
1 parent 0b26d7b commit ec8cae1
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions pkg/lang/ir/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,38 +56,35 @@ func (g Graph) compileVSCode() (*llb.State, error) {
}

func (g *Graph) compileJupyter() error {
if g.JupyterConfig != nil {
g.PyPIPackages = append(g.PyPIPackages, "jupyter")
switch g.Language.Name {
case "python":
return nil
default:
return errors.Newf("Jupyter is not supported in %s yet", g.Language.Name)
}
if g.JupyterConfig == nil {
return nil
}

g.PyPIPackages = append(g.PyPIPackages, "jupyter")
switch g.Language.Name {
case "python":
return nil
default:
return errors.Newf("Jupyter is not supported in %s yet", g.Language.Name)
}
return nil
}

func (g Graph) generateJupyterCommand(workingDir string) []string {
if g.JupyterConfig == nil {
return nil
}

if g.JupyterConfig.Token == "" {
g.JupyterConfig.Token = "''"
}

cmd := []string{
"python3", "-m", "notebook",
"--ip", "0.0.0.0", "--notebook-dir", workingDir,
"--NotebookApp.token", g.JupyterConfig.Token,
"--port", strconv.Itoa(config.JupyterPortInContainer),
}

if g.JupyterConfig.Token != "" {
cmd = append(cmd, "--NotebookApp.token", g.JupyterConfig.Token)
} else {
cmd = append(cmd, "--NotebookApp.token", "''")
}

if g.JupyterConfig.Port != 0 {
p := strconv.Itoa(int(config.JupyterPortInContainer))
cmd = append(cmd, "--port", p)
}
return cmd
}

Expand Down

0 comments on commit ec8cae1

Please sign in to comment.