Hi everyone, I'm trying to bind the outputs of a t...
# ask-community
m
Hi everyone, I'm trying to bind the outputs of a task that returns 2 results to 2 different tasks. It would be easy with the functional API but I have to use the imperative API for an unrelated reason. I have been trying to use
bind
a few different ways without being able to separate the outputs of the first task (see simple example below). Does anyone know how to do this? Thanks!
Copy code
flow = prefect.Flow("example-flow")

flow.add_task(task_a)  # Task A returns 2 outputs
flow.add_task(task_b)  # Task B uses the first output of task A
flow.add_task(task_c)  # Task C uses the first output of task A

task_b.bind(job=task_a, flow=flow)
task_c.bind(report=task_a, flow=flow)
j
Hi @Marie - can you give an example/ a bit more info of what the 2 outputs that A returns are?
m
In my use-case it's one int and one dictionary. One way I went around the problem for now is to consider this as a 2-uple and pass the entire 2-uple to task b and task c
j
Yes I think that's going to be your best bet for now. You're right that something like
task_b.bind(job=task_a.result[0], flow=flow)
won't work.
m
Yep, I tried 😅 Are you planning to support something along those lines in the future?
j
Let's open a ticket for future consideration! @Marvin open "Allow separation of task outputs using the imperative API"
👍 1
m
Thank you for your answer @Jenny
👍 1