How to use step fixtures to access the active ZenML stack from within a step
StepContext
to the input signature of your step. This object will provide additional context inside your step function, and it will give you access the related artifacts, materializers, and stack components directly from within the step.
context
.BaseParameters
, you do not need to create a StepContext
object yourself and pass it when creating the step. As long as you specify a parameter of type StepContext
in the signature of your step function or class, ZenML will automatically create the StepContext
and take care of passing it to your step at runtime.
StepContext
inside a step, ZenML disables caching for this step
by default as the context provides access to external resources which might
influence the result of your step execution. To enable caching anyway,
explicitly enable it in the @step
decorator with @step(enable_cache=True)
or when initializing your custom step class.StepContext
object for. For example, to access materializers, artifact locations, etc:
StepContext
provides.Environment
, which can be used to get further information about the environment where the step is executed, such as the system it is running on, the Python version, the name of the current step, pipeline, and run, and more.
As an example, this is how you could use the Environment
to find out the name of the current step, pipeline, and run:
Environment
, please consult the API docs section on
Environment.