If I have a conditional check in my flow thats something like
Copy code
with case(cond, True):
val1_if_true = action1_if_true()
val2_if_true = action2_if_true()
with case(cond, False):
val_if_false = action_if_false()
What (if anything) do I pass to the merge function?
โ 1
a
Anna Geller
07/13/2022, 6:16 PM
merge is used to execute downstream tasks based on some chosen path e.g.
Copy code
from random import random
from prefect import task, Flow, case
from prefect.tasks.control_flow import merge
...
with Flow("conditional-branches-with-merge") as flow:
cond = check_condition()
with case(cond, True):
val1 = action_if_true()
with case(cond, False):
val2 = action_if_false()
val = merge(val1, val2)
another_action(val)
Anna Geller
07/13/2022, 6:17 PM
what was your intention behind
val2_if_true = action2_if_true()
? this should be after merge
Anna Geller
07/13/2022, 6:17 PM
this is much easier in 2.0 - a good reason to consider migration already
j
Josh Paulin
07/13/2022, 6:19 PM
Ahh. Ok so in that case I guess I donโt need the merge. The actual tasks are something like
1. Case 1: Write to 2 places
2. Case 2 Write a 3rd place
Not really using the results anywhere.
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.