You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi - Below is an example of a flow where one of the branches has a task with skip_on_upstream_skip=False and the trigger any_successful. As the diagram shows both branches of the flow are called.
One way to get around this is to use the trigger not_all_skipped. However is there a legitimate use case for a trigger handling results the results in it's own branch?
Code
import prefect
from prefect import Flow, task, apply_map, Parameter, unmapped
from prefect.tasks.control_flow import ifelse
import random
@task
def list_maker(input_num):
print(input_num)
lst = [random.randint(1, 10) for i in range(input_num)]
print(lst)
return lst
@task(
trigger=prefect.triggers.any_successful,
skip_on_upstream_skip=False
)
def expensive_func(num_from_input):
return 5*num_from_input
@task
def is_even(input_num):
return (input_num % 2) == 0
@task
def odd_num(input_num):
raise Exception()
return 10*input_num
with Flow("map the map") as flow1:
input_num = Parameter("input_num", default=3)
random_list = list_maker(input_num)
odd_res = odd_num(input_num)
ifelse(
is_even(input_num),
random_list,
odd_res
)
expensive_res = expensive_func.map(random_list)
flow1.visualize()
state = flow1.run(
parameters=dict(input_num=3)
)
flow1.visualize(flow_state=state)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi - Below is an example of a flow where one of the branches has a task with
skip_on_upstream_skip=False
and the triggerany_successful
. As the diagram shows both branches of the flow are called.One way to get around this is to use the trigger
not_all_skipped
. However is there a legitimate use case for a trigger handling results the results in it's own branch?Code
Beta Was this translation helpful? Give feedback.
All reactions