@Marvin How do I get the name of a flow from within the flow using the Python API?
m
Marvin
04/13/2024, 8:10 PM
To get the name of a flow from within the flow using the Prefect Python API, you can use the
prefect.runtime
module. For example:
Copy code
python
from prefect import flow
from prefect.runtime import flow_run
@flow
def my_flow():
flow_name = flow_run.flow_name
print(f"The name of this flow is {flow_name}")
my_flow()
By accessing
flow_run.flow_name
, you're able to retrieve the name of the flow that is currently running.
Here's the documentation section that contains more information about accessing flow information from within the flow itself.
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.