Traceback (most recent call last):
File "test_mult_ret.py", line 11, in <module>
double, triple = double_and_triple.map(x=a)
File "/home/macmenaminpe/.local/lib/python3.8/site-packages/prefect/core/task.py", line 1034, in __iter__
raise TypeError(
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.
Philip MacMenamin
04/28/2022, 3:39 PM
(same if:
Copy code
@task(nout=2)
a
Anna Geller
04/28/2022, 3:54 PM
nout is the right approach here. But it doesn't work with mapped tasks, check this open issue
p
Philip MacMenamin
04/28/2022, 3:59 PM
Is the work around to just bundle your return into an object and return that? Or is there a nicer way of doing things?
Philip MacMenamin
04/28/2022, 4:04 PM
Hmm.. this works, but I guess that extra
zip_task
task might be nicer.
k
Kevin Kho
04/28/2022, 4:22 PM
Yeah you need to bundle it as a list or dict. A
zip_task
is not quite the right concept. The
double_and_triple
task returns a
Tuple
so mapping returns a
List[Tuple]
. So if you map over 10 items, you get 10 Tuples.
x, y = something
in Python means that iterable has 2 items. It assumed the output type is
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.