Skip to content

Latest commit

History

History
39 lines (29 loc) 路 1.44 KB

fetch-metadata-within-steps.md

File metadata and controls

39 lines (29 loc) 路 1.44 KB
description
Accessing meta information in real-time within your pipeline.

Fetch metadata within steps

Using the StepContext

To find information about the pipeline or step that is currently running, you can use the zenml.get_step_context() function to access the StepContext of your step:

from zenml import step, get_step_context

@step
def my_step():
    step_context = get_step_context()
    pipeline_name = step_context.pipeline.name
    run_name = step_context.pipeline_run.name
    step_name = step_context.step_run.name

Furthermore, you can also use the StepContext to find out where the outputs of your current step will be stored and which Materializer class will be used to save them:

@step
def my_step():
    step_context = get_step_context()
    # Get the URI where the output will be saved.
    uri = step_context.get_output_artifact_uri()

    # Get the materializer that will be used to save the output.
    materializer = step_context.get_output_materializer() 

{% hint style="info" %} See the SDK Docs for more information on which attributes and methods the StepContext provides. {% endhint %}

ZenML Scarf