Skip to content

Commit

Permalink
bug: fix channels when use conda install with yaml file (#831)
Browse files Browse the repository at this point in the history
* fix conda

Signed-off-by: Jinjing.Zhou <allenzhou@tensorchord.ai>

* add test

Signed-off-by: Jinjing.Zhou <allenzhou@tensorchord.ai>

* add cpuonly

Signed-off-by: Jinjing.Zhou <allenzhou@tensorchord.ai>

Signed-off-by: Jinjing.Zhou <allenzhou@tensorchord.ai>
  • Loading branch information
VoVAllen committed Aug 31, 2022
1 parent be02a70 commit 5e7c182
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions e2e/language/python_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,14 @@ var _ = Describe("python", Ordered, func() {
e.DestroyContainer()()
e.RemoveImage()()
})

It("Should build conda with channel successfully", func() {
exampleName := "python/conda"
testcase := "e2e"
e := e2e.NewExample(buildContextDirWithName(exampleName), testcase)
e.BuildImage(true)()
e.RunContainer()()
e.DestroyContainer()()
e.RemoveImage()()
})
})
3 changes: 3 additions & 0 deletions e2e/language/testdata/python/conda/build.envd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def build():
install.conda_packages(env_file = "env.yaml")
base(os="ubuntu20.04", language="python3.8")
6 changes: 6 additions & 0 deletions e2e/language/testdata/python/conda/env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
channels:
- pytorch
- defaults
dependencies:
- pytorch=1.11.0
- cpuonly
2 changes: 2 additions & 0 deletions pkg/lang/ir/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ func CondaPackage(deps []string, channel []string, envFile *string) error {
}
DefaultGraph.CondaConfig.CondaPackages = append(DefaultGraph.CondaConfig.CondaPackages, parsed.CondaPackages...)
DefaultGraph.PyPIPackages = append(DefaultGraph.PyPIPackages, parsed.PipPackages...)
DefaultGraph.CondaConfig.AdditionalChannels = append(
DefaultGraph.CondaConfig.AdditionalChannels, parsed.Channels...)
}
if len(channel) != 0 {
DefaultGraph.CondaConfig.AdditionalChannels = append(
Expand Down
3 changes: 3 additions & 0 deletions pkg/lang/ir/parser/conda.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type CondaEnv struct {
EnvName string
CondaPackages []string
PipPackages []string
Channels []string
}

func ParseCondaEnvYaml(condaEnvFile string) (*CondaEnv, error) {
Expand All @@ -34,6 +35,8 @@ func ParseCondaEnvYaml(condaEnvFile string) (*CondaEnv, error) {
return nil, errors.Wrapf(err, "failed to read the Conda Env File %s", condaEnvFile)
}
env.EnvName = config.GetString("name")
env.Channels = config.GetStringSlice("channels")

for _, dependencies := range config.Get("dependencies").([]interface{}) {
switch dep := dependencies.(type) {
case string:
Expand Down

0 comments on commit 5e7c182

Please sign in to comment.