Skip to content

Commit 9e0268f

Browse files
authored
[Pipeline] Improve pipeline node name update logic (Azure#28044)
* Improve pipeline node name update logic * update changelog
1 parent c45589e commit 9e0268f

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

sdk/ml/azure-ai-ml/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Added stricter behavior for ArmStr schemas when parsing 'azureml:' prefix.
1212
- Improved intellisense with VS Code for fields supporting local paths and datastores.
1313
- Added validation for token generation with aml scope when user_identity is used in job definition aka OBO flow
14+
- Fixed duplicate node name error in pipeline when two node names assigned to the same node and get renamed by node.name='xx'.
1415

1516
### Other Changes
1617
- Removed dependency on API version 2021-10-01 and 2022-06-01-preview to reduce side of azure-ai-ml package.

sdk/ml/azure-ai-ml/azure/ai/ml/dsl/_pipeline_component_builder.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ def _get_name_or_component_name(node: Union[BaseNode, AutoMLJob]):
366366
# TODO(1979547): refactor this
367367
if not isinstance(v, (BaseNode, AutoMLJob, PipelineJob, ControlFlowNode)):
368368
continue
369-
if getattr(v, "_instance_id", None) not in valid_component_ids:
369+
instance_id = getattr(v, "_instance_id", None)
370+
if instance_id not in valid_component_ids:
370371
continue
371372
name = getattr(v, "name", None) or k
372373
if name is not None:
@@ -380,7 +381,7 @@ def _get_name_or_component_name(node: Union[BaseNode, AutoMLJob]):
380381
)
381382

382383
# Raise error when setting a name that already exists, likely conflict with a variable name
383-
if name in local_names:
384+
if name in local_names and instance_id not in id_name_dict:
384385
raise UserErrorException(
385386
f"Duplicate node name found in pipeline: {self.name!r}, "
386387
f"node name: {name!r}. Duplicate check is case-insensitive."

sdk/ml/azure-ai-ml/tests/dsl/unittests/test_dsl_pipeline.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,18 @@ def pipeline_with_user_defined_nodes_2():
509509
"microsoftsamplescommandcomponentbasic_nopaths_test_2",
510510
]
511511

512+
@dsl.pipeline(name="pipeline_with_user_defined_nodes_3")
513+
def pipeline_with_user_defined_nodes_3():
514+
node1 = component_func1()
515+
node1.name = "my_node"
516+
node2 = node1
517+
518+
pipeline = pipeline_with_user_defined_nodes_3()
519+
variable_names = list(pipeline.component.jobs.keys())
520+
pipeline_job_names = list(pipeline.jobs.keys())
521+
assert variable_names == pipeline_job_names
522+
assert variable_names == ["my_node"]
523+
512524
@dsl.pipeline(name="pipeline_with_duplicate_user_defined_nodes_1")
513525
def pipeline_with_duplicate_user_defined_nodes_1():
514526
node1 = component_func1()

0 commit comments

Comments
 (0)