hi everyone, just a quick question, how can i get ...
# ask-community
j
hi everyone, just a quick question, how can i get the current flow run name programmatically using python during the run? couldn’t find the doc atm…
1
j
hey James, maybe
Copy code
from prefect.context import get_run_context
get_run_context().flow_run.name
could help
j
thanks for the reply! just tried it, it seems
get_run_context()
just gives me a Task Context because I called it under a Task… can I get the Flow Run name inside of a Task?
j
take a look into the get_run_context implementation. it returns the FlowRunContext or TaskRunContext depending on from where it is called. i'm not sure if the flow run context is available from within a task but you could try getting it directly via
FlowRunContext.get()
wit FlowRunContext imported from prefect.context
ahh. see the docstring of FlowRunContext:
Data in this context is only available from within a flow run function.
This sounds to me like this is only available directly inside the flow function. what about getting the name in the flow and passing it on to the tasks?
j
hmm.. yeah seems to be the only way! thx