https://prefect.io logo
Title
i

itay livni

11/29/2019, 6:31 PM
Hi - I have a a`Flow` with a an
ifelse
the
False
branch is a
pass
.
calced_def_df = calced_def_df.copy()
Is that the right way to implement this logic? I am getting a
UserWarning: You are making a copy of a task that has dependencies on or to other tasks in the active flow context. The copy will not retain those dependencies.
"You are making a copy of a task that has dependencies on or to other tasks "
j

Jeremiah

11/29/2019, 6:32 PM
Hi Itay, that warning is to let you know that the task you are copying has already been used elsewhere in your flow, and making sure you’re aware that even though you’re copying it, none of the tasks it was previously connected to are also being copied
If that’s ok with you, you can disregard the message
i

itay livni

11/29/2019, 6:40 PM
Ok. Thanks it makes sense, Is copy
df
the right way to mimic a pass in an
ifelse ?
@Chris White is there a good pattern for ifelse pass?
c

Chris White

11/30/2019, 1:07 AM
Hey itay - so are you trying to implement: If some condition is true, run task A, else if it’s False, skip task A?
i

itay livni

11/30/2019, 1:46 AM
yes
c

Chris White

11/30/2019, 1:49 AM
Gotcha; in that case it might be simpler to raise a skip signal either in the upstream task that is returning the condition or in the task you want to skip - you could pass the output of the condition to the downstream and raise conditional on its value
i

itay livni

11/30/2019, 1:54 AM
Do you have a simple example you can point me to?
c

Chris White

11/30/2019, 1:55 AM
Yup give me a few min I’ll cook something up
i

itay livni

11/30/2019, 1:57 AM
cool! I think it would be good to have in the documentation
c

Chris White

11/30/2019, 2:01 AM
So similar to this example but with a SKIP signal instead of RETRY: https://docs.prefect.io/core/concepts/execution.html#state-signals
for example
@task
def upstream_conditional_task():
    # do stuff
    if some_value is False:
        raise signals.SKIP("Skip this task and any downstream tasks.")
similarly, you could return from the conditional task and perform this check in the downstream
calced_def_df
task, and raise the signal there
i

itay livni

11/30/2019, 2:38 AM
ok. Thanks. diesting
digesting