im having some trouble with map_task and would app...
# flyte-support
g
im having some trouble with map_task and would appreciate support my task:
def *train_aggregator*(_fold_: str) -> str:
in workflow:
map_task(train_aggregator)(_fold_=['fold1', 'fold2'])
but error is complaining about mismatch between string and list of strings
he output variable 'main.map_train_aggregator_6b3bd0353da5de6e84d7982921ead2b3-arraynode.o0' has type [collection_type:{simple:STRING}], but it's assigned to the input variable 'o0' which has type type [simple:STRING].
from my understanding, and confirmed by LLM, map_task should handle this
p
What is your workflow returning?
map_task(train_aggregator)(_fold_=['fold1', 'fold2'])
will also return a
list[str]
rather than just
str
-- is your workflow properly expecting that return value to be a list?
g
oh that might be the issue, workflow returning str
thanks! that was the issue
p
No worries, I've hit that one myself many times so I'm familiar with the error message
🤝 1
g
if I add a second (constant) variable to the map_task, do I need to change the wf output again?
p
ah, hold one sec -- you'll need to use a
partial
task to do that (but to answer your specific question, the output won't change)
Copy code
import functools


@workflow
def multiple_inputs_map_workflow(list_q: list[int] = [1, 2, 3, 4, 5], p: float = 6.0, s: float = 7.0) -> list[float]:
    partial_task = functools.partial(multi_input_task, price=p, shipping=s)
    return map_task(partial_task)(quantity=list_q)
so you just pass the list you want to loop over into the
map_task
, the rest (constant args) get defined as the
partial
g
got it, thank you so much
p
no problem!