<#3120 [Core feature] Map tasks with default argum...
# flyte-github
a
#3120 [Core feature] Map tasks with default arguments Issue created by klekass Motivation: Why do you think this is important? Currently map_tasks does not provide an option to pass default arguments to the mapped function. The documentation suggests to create an additional input preparation task, to prepare parallelized input and default inputs in a single paralellizable list, which adds unnecessary complexity to the workflow execution graph. The idea is, to add an option to pass default arguments to the map_task wrapper, similar to the functools.partial() method. Goal: What should the final outcome look like, ideally? The first task in the following example workflow uses the currently implemented map_task function, to parallelize the 'parallel_task' over a list of inputs. The second task in the workflow is an example of how the map_task could be used with default arguments. The idea is, to parallelize the
parallel_task_with_default
over a list of inputs, where each element is passed to
inp1
.
inp2
should be a default input, equal for all parallel calls of the task.
Copy code
@task
def parallel_task(inp: int) -> int:
    return inp ** 2


@task
def parallel_task_with_default(inp1: int, inp2: int) -> int:
    return inp1 ** 2 + inp2


@workflow
def square_workflow(inp1: List[int], inp2: int) -> None:
    # Supported
    out1 = map_task(parallel_task)(inp=inp1)

    # Not supported!
    out2 = map_task(parallel_task_with_default, inp2=inp2)(inp1=inp1)
Describe alternatives you've considered A potential workaround is explained in the documentation. Propose: Link/Inline OR Additional context No response Are you sure this issue hasn't been raised already? ☑︎ Yes Have you read the Code of Conduct? ☑︎ Yes flyteorg/flyte