https://prefect.io logo
Title
o

Ovo Ojameruaye

02/28/2022, 6:40 AM
Hi, my state of my flow is set as successful even though task fail. I am not sure why this happens. I have a parent flow which create and runs multiple child flows. A task in a child flow fails but the child flow is marked as successful so other downstream child flows run when they shouldn't. Each child flow (1-5) has a create_flow_run and wait_for_flow_run(). Child flow 2 and 5 wait_for_flow_run() have been set has reference task so the parent flow is successful if they both complete. A task fails in child flow 3 but the flow is marked as successful
a

Anna Geller

02/28/2022, 10:33 AM
Can you move the code block and the image in the posts below to this thread to keep the main channel cleaner? There is one flag on the
wait_for_flow_run
task that you need to set to raise Failure in the parent flow upon a failure in a child flow:
raise_final_state=True
Here is an example in a flow:
from prefect import Flow
from prefect.tasks.prefect import create_flow_run, wait_for_flow_run

with Flow("parent_flow") as flow:
    child_flow_run_id = create_flow_run(
        flow_name="child_flow_name", run_name="custom_run_name"
    )
    child_flowrunview = wait_for_flow_run(
        child_flow_run_id, raise_final_state=True, stream_logs=True
    )
o

Ovo Ojameruaye

03/01/2022, 6:25 AM
Thanks Anna, Cleaned up the main thread, actually though I was placing those with this thread, lol
It's odd but when I add the raise_final_state argument, I get TypeError: got an unexpected keyword argument 'raise_final_state'. I am on o.15.3
a

Anna Geller

03/01/2022, 10:37 AM
Can you share your flow in that case? This flag was introduced in 0.15.8 so this should work, unless your agent or execution environment uses an older Prefect version