https://prefect.io logo
Title
i

itay livni

10/22/2019, 8:37 PM
How do you retrieve the results from an
ifelse
? Thanks
c

Chris White

10/22/2019, 8:50 PM
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

10/23/2019, 1:23 AM
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.
c

Chris White

10/23/2019, 2:06 AM
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)