Hi, I have a test workflow that iterates through a...
# flyte-support
m
Hi, I have a test workflow that iterates through a list. I want each launch plan to execute independently, but be aborted if any of the others fail. I received the following message: > "Cascading abort as parent execution id [a5mp9ssvhzcngnfnfbr2] aborted, reason [Some node execution failed, auto-abort.]" Here is my code — does anyone know how to fix this?
Copy code
from typing import Dict, List

from flytekit import LaunchPlan, dynamic, task, workflow

@task
def retrieve_a_list() -> List[int]:
    return [int(i) for i in range(100)]

@task
def print_num_task(num: int):
    if float(num) // 2:
        raise Exception("num is odd")
    print(num)

@workflow
def print_num(num: int):
    print_num_task(num=num)


print_num_lp = LaunchPlan.get_or_create(workflow=print_num)
@workflow
def print_number_wf():
    for num in [1,2,3,4,5,6,7,8,9,10]:
        print_num_lp(num=num)

if __name__ == "__main__":
    print_number_wf()
I intentionally created the failed task.
g
Yeah, you can set the WorkflowFailurePolicy. e.g.:
@workflow(failure_policy=WorkflowFailurePolicy.FAIL_AFTER_EXECUTABLE_NODES_COMPLETE)
def print_number_wf():
....
m
Thanks for the quick response! I will test it.
g
m
It works, thanks!
a