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
Jenny
06/11/2021, 2:22 PM
Hi @Marie - can you give an example/ a bit more info of what the 2 outputs that A returns are?
m
Marie
06/11/2021, 2:25 PM
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
Jenny
06/11/2021, 2:43 PM
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
Marie
06/11/2021, 3:24 PM
Yep, I tried 😅 Are you planning to support something along those lines in the future?
j
Jenny
06/11/2021, 3:49 PM
Let's open a ticket for future consideration! @Marvin open "Allow separation of task outputs using the imperative API"
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.