<@ULVA73B9P> how do i get the name of a flow run from within a task
t
@Marvin how do i get the name of a flow run from within a task
m
To get the name of a flow run from within a task in Prefect, you can utilize the runtime context which is a feature of Prefect that provides information about the current run. The runtime context contains multiple key-value pairs, including the flow run name. The documentation does not provide a direct example of retrieving the flow run name, so you would typically access the runtime context dictionary within your task function like so:
Copy code
python
from prefect import task, Flow
from prefect.context import get_run_context

@task
def task_with_flow_run_info():
    context = get_run_context()
    flow_run_name = context.run_name
    print(f"The name of this flow run is: {flow_run_name}")

with Flow("My Flow") as flow:
    task_with_flow_run_info()

# Run the flow
flow.run()
Please adjust the above code snippet to match the actual keys used in the Prefect context for the version you are using. If the key for the flow run name is different, you can inspect the
context
variable to find the correct one. For a deeper dive into the runtime context, visit the Runtime Context documentation or check the execution logs for information provided by Prefect.