Adding environment variable

Environment can be added in both Python task and Container task, so when you define the python task config or container task config, we can give the env as follows:

  • Python task config: you can pass the environment variables in the config by using env argument which takes dict as input, where key and value both are strings.
from truefoundry.workflow import task, workflow, PythonTaskConfig, TaskDockerFileBuild
from truefoundry.deploy import Resources

task_config = PythonTaskConfig(
    image=TaskDockerFileBuild(...),
  env: {
  	"env_variable_name": "value_of_env_variable",
    ...
  }
)

@task(task_config=task_config)
...
  • Container task config: The container task config also takes env as input argument, similar to python task config , where you can pass the env variable in key value pair as dict.
from truefoundry.workflow import task, workflow, ContainerTaskConfig, ContainerTask
from truefoundry.deploy import Image

container_task = ContainerTask(
    name="container_task",
    task_config=ContainerTaskConfig(
        image=Image(...),
    env: {
      "env_variable_name": "value_of_env_variable",
      ...
    }             
    ),
)

...