Is there a nice way to map with tasks that return tuples? Here’s what we had without mapping: ```par...
r
Is there a nice way to map with tasks that return tuples? Here’s what we had without mapping:
Copy code
part1, part2 = my_tuple_task(input)
otherresult1 = othertask1(part1)
otherresult2 = othertask2(part2)
However now we want to map over multiple inputs to have multiple parallel pipelines of the above:
Copy code
whole_tuple_result = my_tuple_task.map(inputs)
otherresult1 = othertask1.map(whole_tuple_result) # tasks must break up tuple inside the function
otherresult2 = othertask2.map(whole_tuple_result)
Is there a way to maintain the elegant tuple-destructuring while still mapping over the result? Just trying to do it directly gives the error
Copy code
TypeError: Task is not iterable. If your task returns multiple results, pass nout to the task decorator/constructor, or provide a Tuple return-type annotation to your task.
(we’ve already set that which is why the first example works)
k
There is a relevant PR ongoing for this here .
👍 1
So the quick answer is there is no nice way yet…no need to read the whole discussion there, but you may be interested. 😅
r
thanks - looks like it’s going to end up the too-hard basket, but I can live with doing it the ugly way I guess 😛