https://prefect.io logo
Title
m

Marcos

03/28/2023, 11:51 AM
Hi. I've been searching here but I am not able to exit a flow execution if any of the subflows invoked by the orchestrator/worker pattern fail. I am using
run_deployment
as suggested and I'm not able to evaluate the flow state. I also tried to wrap the
run_deployment
within a task.
@task()
def run_worker(name, flow_run_name, etc....):
    flow_run = run_deployment(
        name=name,
        flow_run_name=flow_run_name,
        timeout=timeout,
        tags=tags,
        poll_interval=poll_interval,
        parameters=parameters,
    )
    if flow_run.is_failed():
        raise FailedRun(message=f"Subflow {flow_run_name} failed to complete successfully.")
What's the best way of chaining up subflows and terminate the parent flow if any subflow fails?
A couple of things, 1) I had to access the
State
sub-object and then 2) I ended up verifying whether the flow run returned a completed state.
```@task()
def run_worker(name, flow_run_name, etc....):
flow_run = run_deployment(
name=name,
flow_run_name=flow_run_name,
timeout=timeout,
tags=tags,
poll_interval=poll_interval,
parameters=parameters,
)
if now flow_run.state.is_completed():
raise FailedRun(message=f"Subflow {flow_run_name} failed to complete successfully.")```