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] Map tasks with default arguments #3120

Closed
2 tasks done
klekass opened this issue Nov 30, 2022 · 4 comments
Closed
2 tasks done

[Core feature] Map tasks with default arguments #3120

klekass opened this issue Nov 30, 2022 · 4 comments
Labels
enhancement New feature or request untriaged This issues has not yet been looked at by the Maintainers
Milestone

Comments

@klekass
Copy link

klekass commented Nov 30, 2022

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.

@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
@klekass klekass added enhancement New feature or request untriaged This issues has not yet been looked at by the Maintainers labels Nov 30, 2022
@welcome
Copy link

welcome bot commented Nov 30, 2022

Thank you for opening your first issue here! 🛠

@LukasBommes
Copy link

This would be a very useful feature for which we also have a need.

@JakubWaikat
Copy link

IMO this would improve the workflow a lot! Would be very graceful for this feature to be implemented.

@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
@hamersaw
Copy link
Contributor

hamersaw commented Aug 7, 2023

This functionality is not available by using partials in tandem with maptasks.

@hamersaw hamersaw closed this as completed Aug 7, 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 untriaged This issues has not yet been looked at by the Maintainers
Projects
None yet
Development

No branches or pull requests

6 participants