i

    itay livni

    2 years ago
    Hi - I have a aFlow 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 "
    Jeremiah

    Jeremiah

    2 years ago
    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

    2 years ago
    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?
    Chris White

    Chris White

    2 years ago
    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

    2 years ago
    yes
    Chris White

    Chris White

    2 years ago
    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

    2 years ago
    Do you have a simple example you can point me to?
    Chris White

    Chris White

    2 years ago
    Yup give me a few min I’ll cook something up
    i

    itay livni

    2 years ago
    cool! I think it would be good to have in the documentation
    Chris White

    Chris White

    2 years ago
    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

    2 years ago
    ok. Thanks. diesting
    digesting