Skip to content

Commit

Permalink
copy metadat over
Browse files Browse the repository at this point in the history
Signed-off-by: Yee Hing Tong <[email protected]>
  • Loading branch information
wild-endeavor committed Dec 8, 2021
1 parent df6a949 commit d72820a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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

0 comments on commit d72820a

Please sign in to comment.