<#3403 [Core feature] Support partial tasks> Issue...
# flyte-github
a
#3403 [Core feature] Support partial tasks Issue created by cosmicBboy Motivation: Why do you think this is important? Currently, invoking tasks in `workflow`s or
dynamic
workflows requires fully-specifying the arguments to a
task
. This behavior is clunky in the context of map tasks, where users need to write a bunch of code to prepare the inputs to a map task (see here. The purpose of this issue is to support partial tasks, which allow users to partially bind inputs to a task so that it can then be invoked with the remaining arguments, similar to https://docs.python.org/3/library/functools.html#functools.partial. Goal: What should the final outcome look like, ideally? Requirements Partial tasks should: 1. support partial task inputs that are python values 2. support partial task inputs that are promises 3. support partial task definitions in the top-level scope of a module 4. support use of partial tasks in map tasks Once partial tasks are implemented, it should look something like: Support partial task inputs that are python values
Copy code
from flytekit import task, workflow, partial

@task
def t1(x: int, y: float) -> float:
    return x + y

@workflow
def wf(y: float):
   partial_t1 = partial(t1, x=5)
   return partial_t1(y=y)
Support partial task inputs that are promises
Copy code
from flytekit import task, workflow, partial

@task
def t1(x: int, y: float) -> float:
    return x + y

@task
def t2() -> int:
    return 5

@workflow
def wf(y: float):
   partial_t1 = partial(t1, x=t2())
   return partial_t1(y=y)
Support partials in the top-level module scope If a user wants to specify partial tasks using python literal values in the top-level scope:
Copy code
from flytekit import task, workflow, partial

@task
def t1(x: int, y: float) -> float:
    return x + y

partial_t1 = partial(t1, x=5)

@workflow
def wf(y: float):
   return partial_t1(y=y)
Support partials in map tasks
Copy code
from flytekit import task, workflow, partial, map_task

@task
def t1(x: int, y: float) -> float:
    return x + y

@workflow
def wf(y: List[float]):
   partial_t1 = partial(t1, x=5)
   return map_task(partial_t1)(y=y)
Describe alternatives you've considered Besides syntactic alternatives, not supporting partial tasks would require writing additional code to make some of Flyte's constructs work (e.g. map tasks with multiple inputs). 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