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

Copy metadata into map task from underlying #766

Merged
merged 1 commit into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions flytekit/core/map_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def __init__(
self._max_concurrency = concurrency
self._min_success_ratio = min_success_ratio
self._array_task_interface = python_function_task.python_interface
if "metadata" not in kwargs and python_function_task.metadata:
kwargs["metadata"] = python_function_task.metadata
super().__init__(
name=name,
interface=collection_interface,
Expand Down
14 changes: 14 additions & 0 deletions tests/flytekit/unit/core/test_map_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ def t1(a: int) -> str:
return str(b)


@task(cache=True, cache_version="1")
def t2(a: int) -> str:
b = a + 2
return str(b)


# This test is for documentation.
def test_map_docs():
# test_map_task_start
Expand Down Expand Up @@ -162,3 +168,11 @@ def many_outputs(a: int) -> (int, str):

with pytest.raises(ValueError):
_ = map_task(many_inputs)


def test_map_task_metadata():
map_meta = TaskMetadata(retries=1)
mapped_1 = map_task(t2, metadata=map_meta)
assert mapped_1.metadata is map_meta
mapped_2 = map_task(t2)
assert mapped_2.metadata is t2.metadata