https://prefect.io logo
Title
a

alexandre kempf

12/04/2019, 4:13 PM
Hello everyone, First, thank you all for this great software 🙂 It is really nice to use 🙂 I want to split the "result" of a task into 2 parts.
@task
def return_2_values(x, y):
    return x, y

with Flow("lolilol") as flow:
    a, b = return_2_values(x=2, y=4)
But I can't because task are not iterable 😕 The only trick I found is to use a dictionary inside my task and then use GetItem. Unfortunaly, with this method, I need to know that is inside "return_values" at the level of the Flow in order to get the correct keys. Is there a way to do it without prior information on the task ? Like a normal python function 🙂
n

nicholas

12/04/2019, 4:24 PM
Hi @alexandre kempf! If I understand your problem correctly, you're having an issue where you need to return two pieces of data from a task and you need to know how to access them, correct?
j

josh

12/04/2019, 4:25 PM
Try something like this where you return as a single object and index accordingly:
@task
def a():
    return 1, 2

with Flow('test') as flow:
    res = a()
    other_task(res[0])
    other_task(res[1])
:upvote: 2
a

alexandre kempf

12/04/2019, 4:25 PM
Hi Nicholas 🙂 Correct 🙂
👍 1
Damned ! I was sure I tried this solution (which is the first thing I though about). Thank you guys 🙂
You have an amazing response time btw 😍
🚀 3
j

josh

12/04/2019, 4:28 PM
Haha anytime!
n

nicholas

12/04/2019, 4:28 PM
Let us know if you have any other questions! 😄