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

add with_overrides to map task #794

Merged
merged 2 commits into from
Jan 4, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion flytekit/core/map_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def _raw_execute(self, **kwargs) -> Any:

def map_task(task_function: PythonFunctionTask, concurrency: int = None, min_success_ratio: float = None, **kwargs):
"""
Use a map task for parallelizable tasks that are run across a List of an input type. A map task can be composed of
Use a map task for parallelizable tasks that run across a list of an input type. A map task can be composed of
any individual :py:class:`flytekit.PythonFunctionTask`.

Invoke a map task with arguments using the :py:class:`list` version of the expected input.
Expand All @@ -230,6 +230,11 @@ def map_task(task_function: PythonFunctionTask, concurrency: int = None, min_suc
all inputs are processed.
:param min_success_ratio: If specified, this determines the minimum fraction of total jobs which can complete
successfully before terminating this task and marking it successful.

``with_overrides`` on a map task can be used to set individual map task resource assigment.
Copy link
Contributor Author

@samhita-alla samhita-alla Dec 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@katrogan, what's the preferred way of assigning resources to individual map tasks–TaskMetadata/Resources or with_overrides?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's with with_overrides but I haven't worked on flytekit in so long I'm not sure if it's changed! cc @wild-endeavor @eapolinario

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you try this out? I believe this should work. calling map_task(t1) produces the map task, and then () on that should produce a Node which should hit https://github.com/flyteorg/flytekit/blob/master/flytekit/core/node.py#L79

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but note that this is on the node... not the map task itself. if you use the map task twice, you have to call with overrides twice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me know when you want a +1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TaskMetadata works, whereas Resources doesn't. I replaced Resources with with_overrides in the docstring and test case.


.. code-block:: python
map_task(my_mappable_task)(...).with_overrides(requests=ResourceRequests(cpu="1", memory="300Mi"), retries=1)
"""
if not isinstance(task_function, PythonFunctionTask):
raise ValueError(
Expand Down