If I have a conditional check in my flow thats som...
# prefect-community
j
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
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)
what was your intention behind
val2_if_true = action2_if_true()
? this should be after merge
this is much easier in 2.0 - a good reason to consider migration already
j
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.
๐Ÿ‘ 1
Planning on moving to 2.0 once itโ€™s GA ๐Ÿ™‚
๐Ÿ™Œ 1
a
great to hear ๐Ÿ‘