Hey everyone, In Prefect, when a flow fails midway...
# ask-community
c
Hey everyone, In Prefect, when a flow fails midway, is there a way to: 1. see all the downstream processs in the ui (Flow diagram) that were affected 2. notify the users via email that the flow is broken affecting these downstream processes?
n
hi @Charles Leung - not necessarily, because prefect 2 dynamically discovers the graph according to your conditional python logic, what is "downstream" of a given point in your workflow is not static however you could probably read
task_run_states
out of the
FlowRunContext
and use that to decide what work is still outstanding at any point in time
c
Thanks Nate, I guess Im a little confused on the usage of the the functions, I ran the following code:
Copy code
@flow
async def earnings_demo_03_2024(env, injected_code):
    logger = get_run_logger()
    hmaster_port_number = await grab_hmaster_port(env)
    conn = await grab_access_port_handle.submit(env, hmaster_port_number)
    conn1 = await grab_access_port_handle.submit(env, hmaster_port_number)
    conn2 = await grab_access_port_handle.submit(env, hmaster_port_number)

    test = get_run_context()
    print(test.task_run_states)

#more tasks downstream of this...
And I see that its returning an emtpy list.. am I using this correctly?
n
hmm i see what you're seeing - let me look into that. not immediately sure why the states are not showing there
as a workaround you could do something like this, but im not a big fan of this
i can try to get back later with a better solution to this