Hi - I have a a`Flow` with a an `ifelse` the `Fals...
# ask-community
i
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
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
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
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
yes
c
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
Do you have a simple example you can point me to?
c
Yup give me a few min I’ll cook something up
i
cool! I think it would be good to have in the documentation
c
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
Copy code
@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
ok. Thanks. diesting
digesting