Kyle McEntush
12/24/2022, 7:19 PM@task
def f(val):
return val * 2, val * 4
then the call in my flow looks like
a, b = f.map([1, 2, 3])
but I get ValueError: not enough values to unpack (expected 2, got 1)
I have confirmed that the code works as expected when not decorated with mapping over @task
(that is, two inputs are returned)Ryan Peden
12/24/2022, 7:40 PM# in a flow
# should set a = 2 and b = 4
a, b = f(1)
But as you mentioned, map
runs the task once for each of the input values, and you get back a list of futures. Each future will resolve to a tuple returned by one of the task runs. Running something like this in your flow might give you what you are looking for:
logger = get_run_logger()
futures = f.map([1, 2, 3])
for future in futures:
a, b = future.result()
<http://logger.info|logger.info>(f"a is {a}, b is {b}")
Kyle McEntush
12/24/2022, 7:45 PM