runtime
Runtime functions
TIP
Note that the documentation is automatically generated from envd/api folder in tensorchord/envd repo. Please update the python file there instead of directly editing file inside envd-docs repo.
WARNING
Enable v1 by adding # syntax=v1
to the 1st line of your envd file.
v1 is experimental and may change in the future. Make sure to freeze the envd version for online CI/CD.
command
def command(commands: Dict[str, str])
Execute commands during runtime
Arguments:
commands
Dict[str, str] - map name to command, similar to MakefileExample usage:
runtime.command(commands={
"train": "python train.py --epoch 20 --notify me@tensorchord.ai",
"run": "python server.py --batch 1 --host 0.0.0.0 --port 8000",
})
You can run envd exec --command train
to train the model.
expose
def expose(envd_port: str, host_port: Optional[str], service: Optional[str],
listen_addr: Optional[str])
Expose port to host Proposal: https://github.com/tensorchord/envd/pull/780
Arguments:
envd_port
str - port inenvd
containerhost_port
Optional[str] - port in the host, if not provided orhost_port=0
,envd
will randomly choose a free portservice
Optional[str] - service namelisten_addr
Optional[str] - address to listen on
daemon
def daemon(commands: List[List[str]])
Run daemon processes in the container Proposal: https://github.com/tensorchord/envd/pull/769
It's better to redirect the logs to local files for debug purposes.
Arguments:
commands
List[List[str]] - run multiple commands in the backgroundExample usage:
runtime.daemon(commands=[
["jupyter-lab", "--port", "8080"],
["python3", "serving.py", ">>serving.log", "2>&1"],
])
environ
def environ(env: Dict[str, str], extra_path: List[str])
Add runtime environments
Arguments:
env
Dict[str, str] - environment name to valueextra_path
List[str] - additional PATHExample usage:
runtime.environ(env={"ENVD_MODE": "DEV"}, extra_path=["/usr/bin/go/bin"])
mount
def mount(host_path: str, envd_path: str)
Mount from host path to container path (runtime)
Arguments:
host_path
str - source path in the host machineenvd_path
str - destination path in the envd container
init
def init(commands: List[str])
Commands to be executed when start the container
Arguments:
commands
List[str] - list of commands