From 0b0de279d8eab44442027de5b11615f1963a7e98 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Fri, 5 May 2023 14:41:12 -0700 Subject: [PATCH] Override node name with a name containing underscore (#1608) * override node_name with a name containing underscore Signed-off-by: Kevin Su * add comment Signed-off-by: Kevin Su --------- Signed-off-by: Kevin Su --- flytekit/core/node.py | 4 +++- tests/flytekit/unit/core/test_node_creation.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/flytekit/core/node.py b/flytekit/core/node.py index 73f951d721..4f7838d2b6 100644 --- a/flytekit/core/node.py +++ b/flytekit/core/node.py @@ -84,7 +84,9 @@ def metadata(self) -> _workflow_model.NodeMetadata: def with_overrides(self, *args, **kwargs): if "node_name" in kwargs: - self._id = kwargs["node_name"] + # 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"] 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():