From e35ac735d8d18a09e2bbb87d6714fb1e2f00c352 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Tue, 25 Apr 2023 14:13:40 -0700 Subject: [PATCH 1/2] override node_name with a name containing underscore Signed-off-by: Kevin Su --- flytekit/core/node.py | 2 +- tests/flytekit/unit/core/test_node_creation.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/flytekit/core/node.py b/flytekit/core/node.py index 73f951d721..bf4dbfe6e6 100644 --- a/flytekit/core/node.py +++ b/flytekit/core/node.py @@ -84,7 +84,7 @@ def metadata(self) -> _workflow_model.NodeMetadata: def with_overrides(self, *args, **kwargs): if "node_name" in kwargs: - self._id = kwargs["node_name"] + self._id = _dnsify(kwargs["node_name"]) if "aliases" in kwargs: alias_dict = kwargs["aliases"] if not isinstance(alias_dict, dict): diff --git a/tests/flytekit/unit/core/test_node_creation.py b/tests/flytekit/unit/core/test_node_creation.py index b8d32e4c8d..da708a8571 100644 --- a/tests/flytekit/unit/core/test_node_creation.py +++ b/tests/flytekit/unit/core/test_node_creation.py @@ -415,7 +415,7 @@ def t1(a: str) -> str: @workflow def my_wf(a: str) -> str: - return t1(a=a).with_overrides(name="foo") + return t1(a=a).with_overrides(name="foo", node_name="t_1") serialization_settings = flytekit.configuration.SerializationSettings( project="test_proj", @@ -427,6 +427,7 @@ def my_wf(a: str) -> str: wf_spec = get_serializable(OrderedDict(), serialization_settings, my_wf) assert len(wf_spec.template.nodes) == 1 assert wf_spec.template.nodes[0].metadata.name == "foo" + assert wf_spec.template.nodes[0].id == "t-1" def test_config_override(): From 120e011dbaf7b3299adfecb0a037e309c48b61df Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Wed, 3 May 2023 10:52:48 -0700 Subject: [PATCH 2/2] add comment Signed-off-by: Kevin Su --- flytekit/core/node.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flytekit/core/node.py b/flytekit/core/node.py index bf4dbfe6e6..4f7838d2b6 100644 --- a/flytekit/core/node.py +++ b/flytekit/core/node.py @@ -84,6 +84,8 @@ def metadata(self) -> _workflow_model.NodeMetadata: def with_overrides(self, *args, **kwargs): if "node_name" in kwargs: + # Convert the node name into a DNS-compliant. + # https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names self._id = _dnsify(kwargs["node_name"]) if "aliases" in kwargs: alias_dict = kwargs["aliases"]