Skip to main content


The @environment decorator specifies environment variables for a step.

Note that @environment is mainly useful for setting special environment variables that need to be present when a container launched by @batch or @kubernetes starts, which happens before any user code is executed. Variables that are needed after the user code has started can be set as usual in Python:

import os
os.environ['SOME_VAL'] = "some value"

To set credentials and other secret as environment variables, see the @secrets decorator.



from metaflow import environment

Specifies environment variables to be set prior to the execution of a step.


vars: Dict[str, str], default {}

Dictionary of environment variables to set.