Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core feature] Support partial tasks #3403

Closed
2 tasks done
cosmicBboy opened this issue Mar 6, 2023 · 0 comments
Closed
2 tasks done

[Core feature] Support partial tasks #3403

cosmicBboy opened this issue Mar 6, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@cosmicBboy
Copy link
Contributor

Motivation: Why do you think this is important?

Currently, invoking tasks in workflows 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

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

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:

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

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
@cosmicBboy cosmicBboy added enhancement New feature or request untriaged This issues has not yet been looked at by the Maintainers labels Mar 6, 2023
@cosmicBboy cosmicBboy added this to the 1.5.0 milestone Mar 6, 2023
@eapolinario eapolinario modified the milestones: 1.5.0, 2023 Q1 Backlog Mar 13, 2023
@kumare3 kumare3 self-assigned this Mar 20, 2023
@kumare3 kumare3 removed the untriaged This issues has not yet been looked at by the Maintainers label Mar 20, 2023
@kumare3 kumare3 closed this as completed May 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants