Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support env vars for predict & run #1253

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/cli/predict.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
)

var (
envFlags []string
inputFlags []string
outPath string
)
Expand All @@ -49,6 +50,7 @@ the prediction on that.`,

cmd.Flags().StringArrayVarP(&inputFlags, "input", "i", []string{}, "Inputs, in the form name=value. if value is prefixed with @, then it is read from a file on disk. E.g. -i [email protected]")
cmd.Flags().StringVarP(&outPath, "output", "o", "", "Output path")
cmd.Flags().StringArrayVarP(&envFlags, "env", "e", []string{}, "Environment variables, in the form name=value")

return cmd
}
Expand Down Expand Up @@ -110,6 +112,7 @@ func cmdPredict(cmd *cobra.Command, args []string) error {
GPUs: gpus,
Image: imageName,
Volumes: volumes,
Env: envFlags,
})

go func() {
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func newRunCommand() *cobra.Command {

// This is called `publish` for consistency with `docker run`
cmd.Flags().StringArrayVarP(&runPorts, "publish", "p", []string{}, "Publish a container's port to the host, e.g. -p 8000")
cmd.Flags().StringArrayVarP(&envFlags, "env", "e", []string{}, "Environment variables, in the form name=value")

flags.SetInterspersed(false)

Expand All @@ -55,6 +56,7 @@ func run(cmd *cobra.Command, args []string) error {

runOptions := docker.RunOptions{
Args: args,
Env: envFlags,
GPUs: gpus,
Image: imageName,
Volumes: []docker.Volume{{Source: projectDir, Destination: "/src"}},
Expand Down