Hey, was wondering if mapped tasks are able to out...
# prefect-community
f
Hey, was wondering if mapped tasks are able to output multiple values with nout ? i have an error when trying with dummy code:
Copy code
from asyncio.log import logger
import prefect, pymongo, datetime
from prefect import task, Flow, flatten
from prefect.tasks.secrets import PrefectSecret
from prefect.tasks.mysql.mysql import MySQLFetch
from prefect.storage import GitHub

@task(nout= 3)
def produce_output(input):
    return input*2-1, input*2, ["val"+str(input*2-1), "val"+str(input*2)]

@task
def reduce(a):
    return sum(a)

@task
def retry_post(data):
    logger = prefect.context.get("logger")
    <http://logger.info|logger.info>(data)

with Flow("abcdef") as flow:
    success, fail, to_retry = produce_output.map([1, 2, 3, 4])
    total_success = reduce(success)
    total_fail = reduce(fail)
    retry_post.map(flatten(to_retry))

flow.run()
1
a
It's a known issue - you would need to return it as a list rather than a tuple, e.g.
Copy code
@task
def produce_output(input):
    return [input*2-1, input*2, ["val"+str(input*2-1), "val"+str(input*2)]]
f
ok thanks !
👍 1