<#812 feat: add flyte_map built-in for parallel ta...
# flyte-github
a
#812 feat: add flyte_map built-in for parallel task execution in code-mode workflow sandboxing Pull request opened by kumare3 Sandbox code (Monty runtime) cannot
import flyte
, so
flyte.map
is not directly available. This adds
flyte_map
as a bridge-level built-in that delegates to
flyte.map.aio
, giving sandboxed code access to parallel task execution with the same semantics as
flyte.map
. Usage in sandbox code strings:
Copy code
# Map a single-arg task over a list (parallel)
flyte_map("double", items)

# Multiple iterables are zipped, like flyte.map
flyte_map("add", xs, ys)

# All flyte.map kwargs are supported
flyte_map("double", items, concurrency=4, return_exceptions=True)

# Results are collected into a list for further processing
squared = flyte_map("square", items)
total = 0
for v in squared:
    total = total + v
total
The first argument is always the task name as a string. The task must be registered via the
tasks=[]
parameter of
orchestrator_from_str()
or
orchestrate_local()
. Changes: • _bridge.py: Handle
flyte_map
FunctionSnapshot in the execute loop, resolve task name from refs, delegate to flyte.map.aio, collect results • init.py: Document flyte_map in ORCHESTRATOR_SYNTAX_PROMPT • examples/sandbox/code_string.py: Add Examples 8-9 (batch map, map+reduce) • examples/sandbox/dynamic_code.py: Add Pattern 5 with local execution tests • tests/flyte/sandbox/test_map_in_sandbox.py: 16 tests covering for-loop pattern, flyte_map basics, kwargs forwarding, error handling, and templates flyteorg/flyte-sdk