Skip to content

Commit b180e26

Browse files
authored
[ML][Pipelines] Remove prefix in pipeline component jobs (Azure#28153)
* Remove prefix in pipeline component jobs Signed-off-by: Brynn Yin <[email protected]> * Fix bug Signed-off-by: Brynn Yin <[email protected]> Signed-off-by: Brynn Yin <[email protected]>
1 parent 9141782 commit b180e26

File tree

3 files changed

+188
-201
lines changed

3 files changed

+188
-201
lines changed

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_component/pipeline_component.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import json
88
import logging
9+
import re
910
import typing
1011
from collections import Counter
1112
from typing import Dict, Optional, Tuple, Union
@@ -16,7 +17,7 @@
1617
from azure.ai.ml._schema import PathAwareSchema
1718
from azure.ai.ml._schema.pipeline.pipeline_component import PipelineComponentSchema
1819
from azure.ai.ml._utils.utils import is_data_binding_expression, hash_dict
19-
from azure.ai.ml.constants._common import COMPONENT_TYPE
20+
from azure.ai.ml.constants._common import COMPONENT_TYPE, ARM_ID_PREFIX, ASSET_ARM_ID_REGEX_FORMAT
2021
from azure.ai.ml.constants._component import ComponentSource, NodeType
2122
from azure.ai.ml.constants._job.pipeline import ValidationErrorCode
2223
from azure.ai.ml.entities._builders import BaseNode, Command
@@ -350,6 +351,10 @@ def _resolve_sub_nodes(cls, rest_jobs):
350351
if rest_jobs is None:
351352
return sub_nodes
352353
for node_name, node in rest_jobs.items():
354+
# TODO: Remove this ad-hoc fix after unified arm id format in object
355+
component_id = node.get("componentId", "")
356+
if isinstance(component_id, str) and re.match(ASSET_ARM_ID_REGEX_FORMAT, component_id):
357+
node["componentId"] = component_id[len(ARM_ID_PREFIX):]
353358
if not LoopNode._is_loop_node_dict(node):
354359
# skip resolve LoopNode first since it may reference other nodes
355360
# use node factory instead of BaseNode._from_rest_object here as AutoMLJob is not a BaseNode

sdk/ml/azure-ai-ml/tests/component/e2etests/test_component.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,6 @@ def test_simple_pipeline_component_create(self, client: MLClient, randstr: Calla
737737
dict(rest_pipeline_component._to_dict()),
738738
"name",
739739
"creation_context",
740-
# jobs not returned now
741740
"jobs",
742741
"id",
743742
)
@@ -762,6 +761,10 @@ def test_simple_pipeline_component_create(self, client: MLClient, randstr: Calla
762761
"type": "pipeline",
763762
}
764763
assert component_dict == expected_dict
764+
jobs_dict = rest_pipeline_component._to_dict()["jobs"]
765+
# Assert full componentId extra azureml prefix has been removed and parsed to versioned arm id correctly.
766+
assert "azureml:azureml_anonymous" in jobs_dict["component_a_job"]["component"]
767+
assert jobs_dict["component_a_job"]["type"] == "command"
765768

766769
def test_helloworld_nested_pipeline_component(self, client: MLClient, randstr: Callable[[str], str]) -> None:
767770
component_path = "./tests/test_configs/components/helloworld_nested_pipeline_component.yml"

0 commit comments

Comments
 (0)