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.
Copy code
@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:
Copy code
@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
alexandre kempf
12/04/2019, 4:26 PM
Damned ! I was sure I tried this solution (which is the first thing I though about). Thank you guys 🙂
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.