<@ULVA73B9P> How do I get the name of a flow from ...
# ask-marvin
r
@Marvin How do I get the name of a flow from within the flow using the Python API?
m
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.