i

    itay livni

    2 years ago
    How do you retrieve the results from an
    ifelse
    ? Thanks
    Chris White

    Chris White

    2 years ago
    anytime you call a task using the functional API, a task copy is made. So in this case, you’d want to capture the return value of
    ifelse(...)
    so you can reference it later:
    ifelse_return = ifelse(...)
    and then after your flow has ran:
    flow_state = flow.run()
    flow_state.result[ifelse_return].result
    i

    itay livni

    2 years ago
    thanks
    Yeah I was not clear. In the
    flow
    I need the result of a branch to feed to the next task in that branch.
    Chris White

    Chris White

    2 years ago
    ah i see; yea check out https://docs.prefect.io/core/tutorials/task-guide.html#adding-tasks-to-flows on when task copies get made; in this case you’d do:
    true_upstream = true_task(y)
    ifelse(check_task(x), true_upstream, false_task(z))
    
    second_true_task.set_upstream(true_upstream, key="arg1")
    # or second_true_task(arg1=true_upstream)