<@ULVA73B9P> I've been reading the <doc> but I do ...
# marvin-ai
j
@Marvin I've been reading the doc but I do not understand it clearly. I am using prefect server, and I hav a flow that runs 4 subflows sequentially. The first flow failed, but the parent flow continued, the other 3 flows runned (and finished as completed) and the parent flow finished completed as well. From what I understood from the doc is that if any flow fails, the flow stops. Moreover, the parent flow returns a list of each returned value from each subflow. So I do not really understand why the parent flow is completed instead of failed.
m
thought for 28.6 seconds
Based on the research and your description, I can explain what's happening and why this behavior might be unexpected. Let me break this down: 1. Default Behavior vs. Exception Handling - By default, if a subflow fails with an unhandled exception, it should propagate to the parent flow and cause it to fail - However, if the subflow's failure is being caught and handled in the parent flow, the parent flow can continue executing 2. Your Specific Case The fact that your parent flow completed successfully despite a subflow failure suggests one of two things: - Either the subflow failures are being caught and handled in your parent flow - Or there might be a specific implementation detail in your flow that's preventing the failure from propagating Could you share the code of your parent flow? This would help me identify exactly why this is happening. The flow should look something like this:
Copy code
python
from prefect import flow

@flow
def parent_flow():
    # If this is wrapped in try/except, that would explain the behavior
    result1 = subflow1()  # This one fails
    result2 = subflow2()
    result3 = subflow3()
    result4 = subflow4()
    return [result1, result2, result3, result4]  # This should include the failed state
3. Expected Behavior - If a subflow fails and the failure is not handled, the parent flow should indeed fail - The parent flow should only complete successfully if: a) All subflows complete successfully, or b) Failed subflows are explicitly handled (e.g., with try/except) 4. Recommendations - If you want the parent flow to fail when any subflow fails, make sure you're not catching exceptions - If you need to handle subflow failures gracefully, you can use try/except but should consider propagating the failure state in your return value - You can also use Prefect's state API to check subflow states explicitly Could you share: 1. The code of your parent flow? 2. How are you calling the subflows (direct calls or using
run_deployment
)? 3. Are there any try/except blocks in your code? This will help me provide more specific guidance on why this is happening and how to achieve the behavior you want.