tensorchord / envd

🏕️ Reproducible development environment
https://envd.tensorchord.ai/
Apache License 2.0
1.95k stars 156 forks source link

feat(lang): Support built-in variables #61

Open gaocegege opened 2 years ago

gaocegege commented 2 years ago

Description

base(os="ubuntu20.04", language="python3")
print(midi.os)

We need to provide some built-in variables to support conditional build like this

if midi.os == "ubuntu":
    ubuntu_apt_source("xxx")
knight42 commented 2 years ago

IIUC, according to the signature of ExecFile, these built-in variables could only be pre-declared, but the value of os is only known to us in runtime(during the execution of the script) as it is the argument of base function.

If our goal is to get the value of os, could we add another function like current_os()? its usage could be like:

base(os="ubuntu20.04", language="python3")
if current_os() == "ubuntu":
  # do something
gaocegege commented 2 years ago

This issue is related to #91

The design purpose of this feature is to support conditional exec. The func approach LGTM but I am not sure if there is any fancy way to achieve this.

https://github.com/maxmcd/bramble gives us some insights.

kemingy commented 1 year ago

Related to #1132