m

    Marie

    1 year ago
    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!
    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)
    Jenny

    Jenny

    1 year ago
    Hi @Marie - can you give an example/ a bit more info of what the 2 outputs that A returns are?
    m

    Marie

    1 year ago
    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
    Jenny

    Jenny

    1 year ago
    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

    1 year ago
    Yep, I tried 😅 Are you planning to support something along those lines in the future?
    Jenny

    Jenny

    1 year ago
    Let's open a ticket for future consideration! @Marvin open "Allow separation of task outputs using the imperative API"
    Marvin

    Marvin

    1 year ago
    m

    Marie

    1 year ago
    Thank you for your answer @Jenny