Environment Variables
Configuring environment variables.
Environment variables can be configured to be available at runtime during step execution. ZenML provides two ways to set environment variables:
Plain text environment variables: Configure key-value pairs directly
Secrets as environment variables: Use ZenML secrets where the secret values become environment variables. Check out this page for more information on secret management in ZenML.
Configuration levels
Environment variables and secrets can be configured at different levels with increasing precedence:
Stack components - Available for all pipelines executed on stacks containing this component
Stack - Available for all pipelines executed on this stack
Pipeline - Available for all steps in this pipeline
Step - Available only for this specific step
Automatic environment variable injection
When executing a pipeline, ZenML automatically scans your local environment for any variables that start with the __ZENML__ prefix and adds them to the pipeline environment. The prefix is removed during this process.
For example, if you set:
export __ZENML__MY_VAR=my_valueIt will be available in your steps as follows:
Configuring environment variables on stack components
Configure environment variables and secrets that will be available for all pipelines executed on stacks containing this component.
Setting environment variables on stacks
Configure environment variables and secrets for all pipelines executed on this stack.
Configuring environment variables on pipelines
Configure environment variables and secrets for all steps of a pipeline. See this page for more details on how to configure pipelines.
Setting environment variables on steps
Configure environment variables and secrets for individual steps. See this page for more details on how to configure steps.
When environment variables are set
The timing of when environment variables are set depends on the orchestrator being used:
The Databricks and Lightning orchestrators will set the environment variables right before your step code is being executed
All other orchestrators set environment variables already at container startup time
Last updated
Was this helpful?