-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lang): Remove conda from custom base image (#626)
* feat(lang): Remove conda from base image Signed-off-by: Ce Gao <cegao@tensorchord.ai> * fix: Fix test Signed-off-by: Ce Gao <cegao@tensorchord.ai> * fix: Fix test cases Signed-off-by: Ce Gao <cegao@tensorchord.ai> * fix: Update Signed-off-by: Ce Gao <cegao@tensorchord.ai> * fix: Update test cases Signed-off-by: Ce Gao <cegao@tensorchord.ai> * fix: Fix case Signed-off-by: Ce Gao <cegao@tensorchord.ai> * fix: Fix test cases Signed-off-by: Ce Gao <cegao@tensorchord.ai> * fix: Update Signed-off-by: Ce Gao <cegao@tensorchord.ai> * fix: Fix test cases Signed-off-by: Ce Gao <cegao@tensorchord.ai> * fix: Move e2e to a separate stage Signed-off-by: Ce Gao <cegao@tensorchord.ai> * fix: Update finish Signed-off-by: Ce Gao <cegao@tensorchord.ai> * fix: Update flag Signed-off-by: Ce Gao <cegao@tensorchord.ai> * fix: Update Signed-off-by: Ce Gao <cegao@tensorchord.ai> * Fix: Update Signed-off-by: Ce Gao <cegao@tensorchord.ai> * Update Signed-off-by: Ce Gao <cegao@tensorchord.ai> * fix: Update Signed-off-by: Ce Gao <cegao@tensorchord.ai> * Fix: Update Signed-off-by: Ce Gao <cegao@tensorchord.ai> * Fix: UPdate Signed-off-by: Ce Gao <cegao@tensorchord.ai> * Fix: Update Signed-off-by: Ce Gao <cegao@tensorchord.ai> * fix: Update Signed-off-by: Ce Gao <cegao@tensorchord.ai> * fix: Update Signed-off-by: Ce Gao <cegao@tensorchord.ai> * fix: Update Signed-off-by: Ce Gao <cegao@tensorchord.ai>
- Loading branch information
Showing
11 changed files
with
265 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
def build(): | ||
base(language="python", image="python:3.8") | ||
install.python_packages(name=[ | ||
"ormb", | ||
"via", | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
def build(): | ||
base(language="python", image="python:3.8") | ||
install.python_packages(name=[ | ||
"via", | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright 2022 The envd Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package ir | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/moby/buildkit/client/llb" | ||
) | ||
|
||
func (g Graph) compileCustomPython(aptStage llb.State) (llb.State, error) { | ||
pypiMirrorStage := g.compilePyPIIndex(aptStage) | ||
|
||
builtinSystemStage := pypiMirrorStage | ||
|
||
systemStage := g.compileCustomSystemPackages(builtinSystemStage) | ||
pypiStage := g.compileCustomPyPIPackages(systemStage) | ||
|
||
return pypiStage, nil | ||
} | ||
|
||
func (g Graph) compileCustomPyPIPackages(root llb.State) llb.State { | ||
if len(g.PyPIPackages) == 0 { | ||
return root | ||
} | ||
|
||
cacheDir := "/home/root/.cache" | ||
|
||
// Compose the package install command. | ||
var sb strings.Builder | ||
// Always use the conda's pip. | ||
sb.WriteString("pip install") | ||
for _, pkg := range g.PyPIPackages { | ||
sb.WriteString(fmt.Sprintf(" %s", pkg)) | ||
} | ||
|
||
cmd := sb.String() | ||
// Refer to https://github.com/moby/buildkit/blob/31054718bf775bf32d1376fe1f3611985f837584/frontend/dockerfile/dockerfile2llb/convert_runmount.go#L46 | ||
cache := root.File(llb.Mkdir("/cache", 0755, llb.WithParents(true)), | ||
llb.WithCustomName("[internal] settings pip cache mount permissions")) | ||
run := root. | ||
Run(llb.Shlex(cmd), llb.WithCustomNamef("pip install %s", | ||
strings.Join(g.PyPIPackages, " "))) | ||
run.AddMount(cacheDir, cache, | ||
llb.AsPersistentCacheDir(g.CacheID(cacheDir), llb.CacheMountShared), | ||
llb.SourcePath("/cache")) | ||
return run.Root() | ||
} | ||
|
||
func (g Graph) compileCustomSystemPackages(root llb.State) llb.State { | ||
if len(g.SystemPackages) == 0 { | ||
return root | ||
} | ||
|
||
// Compose the package install command. | ||
var sb strings.Builder | ||
sb.WriteString("apt-get update && apt-get install -y --no-install-recommends") | ||
|
||
for _, pkg := range g.SystemPackages { | ||
sb.WriteString(fmt.Sprintf(" %s", pkg)) | ||
} | ||
|
||
cacheDir := "/var/cache/apt" | ||
cacheLibDir := "/var/lib/apt" | ||
|
||
run := root.Run(llb.Shlex(fmt.Sprintf("bash -c \"%s\"", sb.String())), | ||
llb.WithCustomNamef("apt-get install %s", | ||
strings.Join(g.SystemPackages, " "))) | ||
run.AddMount(cacheDir, llb.Scratch(), | ||
llb.AsPersistentCacheDir(g.CacheID(cacheDir), llb.CacheMountShared)) | ||
run.AddMount(cacheLibDir, llb.Scratch(), | ||
llb.AsPersistentCacheDir(g.CacheID(cacheLibDir), llb.CacheMountShared)) | ||
return run.Root() | ||
} |
Oops, something went wrong.