Skip to content

Commit

Permalink
feat: abort when trying to run envd up on non-dev images (#1751)
Browse files Browse the repository at this point in the history
* feat: abort when trying to run `envd up` on non-dev images

Signed-off-by: Keming <kemingyang@tensorchord.ai>

* fix v0 dev condition

Signed-off-by: Keming <kemingyang@tensorchord.ai>

---------

Signed-off-by: Keming <kemingyang@tensorchord.ai>
  • Loading branch information
kemingy committed Sep 1, 2023
1 parent e712892 commit d99cfa4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/app/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ func up(clicontext *cli.Context) error {
if err = buildutil.InterpretEnvdDef(builder); err != nil {
return err
}
if !builder.GetGraph().IsDev() {
return errors.New("`envd up` only works for dev images. If you're using v1, please enable dev with `base(dev=True)`.")
}
if err = buildutil.DetectEnvironment(clicontext, buildOpt); err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ func (b generalBuilder) ShmSize() int {
return b.graph.GetShmSize()
}

func (b generalBuilder) IsDev() bool {
return b.graph.IsDev()
}

func (b generalBuilder) Build(ctx context.Context, force bool) error {
if !force && !b.checkIfNeedBuild(ctx) {
return nil
Expand Down
1 change: 1 addition & 0 deletions pkg/lang/ir/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type graphVisitor interface {
GPUEnabled() bool
GetNumGPUs() int
GetShmSize() int
IsDev() bool
Labels() (map[string]string, error)
ExposedPorts() (map[string]struct{}, error)
GetEntrypoint(buildContextDir string) ([]string, error)
Expand Down
4 changes: 4 additions & 0 deletions pkg/lang/ir/v0/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ func NewGraph() ir.Graph {

var DefaultGraph = NewGraph()

func (g generalGraph) IsDev() bool {
return g.Image == nil
}

func (g generalGraph) GetShmSize() int {
return g.ShmSize
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/lang/ir/v1/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ func (g *generalGraph) SetWriter(w compileui.Writer) {
g.Writer = w
}

func (g generalGraph) IsDev() bool {
return g.Dev
}

func (g generalGraph) GetHTTP() []ir.HTTPInfo {
return g.HTTP
}
Expand Down

0 comments on commit d99cfa4

Please sign in to comment.