<#6522 [BUG] map_task with LaunchPlan fails when i...
# flyte-github
a
#6522 [BUG] map_task with LaunchPlan fails when input is a Promise (works remotely but fails locally) Issue created by redartera ## Flyte & Flytekit version Flytekit version: Latest (using Union SDK) ## Describe the bug When using
union.map()
with a LaunchPlan and passing a Promise as input (result from a previous task), the execution fails locally with a
ValueError
but works fine when running remotely. The error specifically occurs when trying to map over a LaunchPlan using the result of a previous task (which is a Promise). The issue is that the local execution expects a concrete list value but receives a Promise object instead. Error message:
Copy code
ValueError: Expected a list of <class 'int'> but got <class 'flytekit.core.promise.Promise'> instead.
## Expected behavior The
union.map(launch_plan)(foo=promise_result)
should work consistently both locally and remotely, similar to how
union.map(task)(foo=promise_result)
works. Both of these patterns should work: 1.
union.map(task)(foo=promise_result)
✅ (works) 2.
union.map(launch_plan)(foo=promise_result)
❌ (fails locally, works remotely) ## Additional context to reproduce Reproduction steps: 1. Create a task that returns a list 2. Create another task and wrap it in a LaunchPlan 3. In a workflow, call the first task to get a Promise result 4. Try to use
union.map(launch_plan)(foo=promise_result)
5. Run locally using
union run
or similar Code example: import union @union.task def t1(foo: int) -> int: return foo @union.workflow() def t1_wf(foo: int) -> int: return t1(foo=foo) t1_lp = union.LaunchPlan.get_or_create(t1_wf) @union.task def t2(foo: int) -> list[int]: return [foo] @union.workflow() def wf(foo: int) -> list[int]: foo_list = t2(foo=foo) # return union.map(t1)(foo=foo_list) # <-- This works # return union.map(t1_lp)(foo=[1,2,3]) # <-- This works return union.map(t1_lp)(foo=foo_list) # <-- This doesn't work locally Working cases: •
union.map(t1)(foo=foo_list)
- mapping over a task with Promise input ✅ •
union.map(t1_lp)(foo=[1,2,3])
- mapping over a LaunchPlan with concrete input ✅ Failing case: •
union.map(t1_lp)(foo=foo_list)
- mapping over a LaunchPlan with Promise input ❌ (locally) This suggests there's a difference in how Promise resolution is handled between tasks and LaunchPlans in local vs remote execution contexts. ## Screenshots Terminal output showing the error:
Copy code
Running Execution on local.
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /root/ai-model-dev/foobar.py:29 in wf                                                            │
│                                                                                                  │
│   26 │   foo_list = t2(foo=foo)                                                                  │
│   27 │   # return union.map(t1)(foo=foo_list) # <-- This works                                 │
│   28 │   # return union.map(t1_lp)(foo=[1,2,3]) # <-- This works                               │
│ ❱ 29 │   return union.map(t1_lp)(foo=foo_list)  # <-- This doesn't work                        │
│   30                                                                                             │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: Expected a list of <class 'int'> but got <class 'flytekit.core.promise.Promise'> instead.
• Are you sure this issue hasn't been raised already? • Have you read the Code of Conduct? flyteorg/flyte