Back to Prefect

How to access runtime information

docs/v3/how-to-guides/workflows/access-runtime-info.mdx

3.6.30.dev3775 B
Original Source

Use the prefect.runtime module to access runtime information from within a workflow.

python
from prefect import flow
from prefect.runtime import flow_run


@flow
def moody_workflow(name: str):
    return f"I wish my parents had named me {name} instead of {flow_run.name}."

The value of flow_run.name will change between workflow runs to match the name of the flow run.

<Note> **Attributes of `prefect.runtime` are `None` if a value is not available**

Attributes of prefect.runtime will never error when accessed. If a value is not available, the attribute will be None.

python
from prefect.runtime import flow_run

assert flow_run.name is None
</Note>

See the prefect.runtime module reference for all available attributes.