https://prefect.io logo
Title
a

Austin Weisgrau

03/23/2023, 8:30 PM
Having trouble accessing the flow name from within a flow using the context for some reason:
Traceback (most recent call last):
  File "/home/aradox/code/wfp/wfp-prefect/utilities/slack.py", line 93, in handled_error_func
    return func(*args, **kwargs)
  File "/home/aradox/code/wfp/wfp-prefect/utilities/van.py", line 213, in alert_new_van_contact
    "flow": get_run_context().flow.name,
AttributeError: 'TaskRunContext' object has no attribute 'flow'
Ah I see, I'm getting a task run context instead of a flow run context
z

Zanie

03/23/2023, 8:35 PM
Hey! Task runs don’t have access to the flow because they may be running on other workers
You can use
FlowRunContext.get()
instead though if you’re always running your tasks locally
a

Austin Weisgrau

03/23/2023, 8:36 PM
Awesome
that's perfect