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

Set map task metadata only for subnode #2979

Merged
merged 2 commits into from
Dec 5, 2024
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
5 changes: 5 additions & 0 deletions flytekit/core/array_node_map_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ def python_interface(self):

def construct_node_metadata(self) -> NodeMetadata:
# TODO: add support for other Flyte entities
return NodeMetadata(
name=self.name,
)

def construct_sub_node_metadata(self) -> NodeMetadata:
nm = super().construct_node_metadata()
nm._name = self.name
return nm
Expand Down
2 changes: 1 addition & 1 deletion flytekit/tools/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ def get_serializable_array_node_map_task(
)
node = workflow_model.Node(
id=entity.name,
metadata=entity.construct_node_metadata(),
metadata=entity.construct_sub_node_metadata(),
inputs=node.bindings,
upstream_node_ids=[],
output_aliases=[],
Expand Down
12 changes: 9 additions & 3 deletions tests/flytekit/unit/core/test_array_node_map_task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import functools
from datetime import timedelta
import os
import tempfile
import typing
Expand Down Expand Up @@ -386,7 +387,12 @@ def test_serialization_metadata2(serialization_settings):
def t1(a: int) -> typing.Optional[int]:
return a + 1

arraynode_maptask = map_task(t1, min_success_ratio=0.9, concurrency=10, metadata=TaskMetadata(retries=2, interruptible=True))
arraynode_maptask = map_task(
t1,
min_success_ratio=0.9,
concurrency=10,
metadata=TaskMetadata(retries=2, interruptible=True, timeout=timedelta(seconds=10))
)
assert arraynode_maptask.metadata.interruptible

@workflow
Expand All @@ -402,16 +408,16 @@ def wf1(x: typing.List[int]):
od = OrderedDict()
wf_spec = get_serializable(od, serialization_settings, wf)

assert arraynode_maptask.construct_node_metadata().interruptible
array_node = wf_spec.template.nodes[0]
assert array_node.metadata.interruptible
assert array_node.metadata.timeout == timedelta()
assert array_node.array_node._min_success_ratio == 0.9
assert array_node.array_node._parallelism == 10
assert not array_node.array_node._is_original_sub_node_interface
assert array_node.array_node._execution_mode == _core_workflow.ArrayNode.MINIMAL_STATE
task_spec = od[arraynode_maptask]
assert task_spec.template.metadata.retries.retries == 2
assert task_spec.template.metadata.interruptible
assert task_spec.template.metadata.timeout == timedelta(seconds=10)

wf1_spec = get_serializable(od, serialization_settings, wf1)
array_node = wf1_spec.template.nodes[0]
Expand Down
Loading