https://prefect.io logo
v

Vamsi Reddy

01/27/2022, 9:03 PM
Hi everyone, so i have a task that return a list of module_names. However this list is not fixed and can vary in length. I am iterating over this list to get the names and then run those modules in a seperate task. Is it possible to specify the output as a list. I tried using nout =1 but it just outputs 1 element of the list.I get the following 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.
k

Kevin Kho

01/27/2022, 9:11 PM
You should be able to. I have something similar in my demo here.
I think you are trying to access a list or dict in the flow block?
v

Vamsi Reddy

01/27/2022, 9:17 PM
so the no of elements in my list is not fixed. but i am sure i will be returning 1 list. then i do
Copy code
for module_name in list:
   process = process_module(module_name)
   tasks.append(process)
here the list length is not fixed since we get the module names from an external file
k

Kevin Kho

01/27/2022, 9:20 PM
Yes it should still work if you pass 1 list as output
4 Views