Skip to content

Commit

Permalink
Override node name with a name containing underscore (#1608)
Browse files Browse the repository at this point in the history
* override node_name with a name containing underscore

Signed-off-by: Kevin Su <[email protected]>

* add comment

Signed-off-by: Kevin Su <[email protected]>

---------

Signed-off-by: Kevin Su <[email protected]>
  • Loading branch information
pingsutw authored May 5, 2023
1 parent a1636a8 commit 0b0de27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion flytekit/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion tests/flytekit/unit/core/test_node_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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():
Expand Down

0 comments on commit 0b0de27

Please sign in to comment.