Skip to content

Commit ef3c233

Browse files
Make component type insensitive (#42592)
* make component type insensitive * fix test
1 parent e13b371 commit ef3c233

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
- Removed the dependencies - msrest and six
88

99
### Bugs Fixed
10+
- Fix for registry resource group passed to OnlineEndpointOperations when model is in registry in different resource group compared to workspace.
11+
- Set defaults for min_instances, max_instances, idle_time_before_scale_down in AmlCompute
12+
13+
### Other Changes
14+
- v2 component types are now case insensitive
1015

1116
## 1.28.1 (2025-07-08)
1217

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,10 @@ def get_type_from_spec(data: dict, *, valid_keys: Iterable[str]) -> str:
600600
"""
601601
_type, _ = extract_label(data.get(CommonYamlFields.TYPE, None))
602602

603+
# Normalize type to lowercase for case-insensitive comparison for sdk v2 component types
604+
if _type and any(_type.lower() == getattr(NodeType, attr) for attr in dir(NodeType)):
605+
_type = _type.lower()
606+
603607
# we should keep at least 1 place outside _internal to enable internal components
604608
# and this is the only place
605609
try_enable_internal_components()

sdk/ml/azure-ai-ml/tests/internal_utils/unittests/test_utils.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@
44

55
import pytest
66

7+
from azure.ai.ml._internal._schema.component import NodeType as InternalNodeType
78
from azure.ai.ml._utils.utils import (
89
_get_mfe_base_url_from_batch_endpoint,
910
dict_eq,
1011
get_all_data_binding_expressions,
12+
get_valid_dot_keys_with_wildcard,
1113
is_data_binding_expression,
1214
map_single_brackets_and_warn,
1315
write_to_shared_file,
14-
get_valid_dot_keys_with_wildcard,
1516
)
17+
from azure.ai.ml.constants._component import NodeType
1618
from azure.ai.ml.entities import BatchEndpoint
17-
from azure.ai.ml.entities._util import convert_ordered_dict_to_dict
19+
from azure.ai.ml.entities._util import convert_ordered_dict_to_dict, get_type_from_spec
20+
from azure.ai.ml.exceptions import ValidationException
1821

1922

2023
@pytest.mark.unittest
@@ -120,3 +123,17 @@ def test_get_valid_dot_keys_with_wildcard(self):
120123
"deep.*.*",
121124
validate_func=lambda _root, _parts: _parts[1] == "l1_2",
122125
) == ["deep.l1_2.l2"]
126+
127+
def test_get_type_from_spec_case_insensitive(self):
128+
"""Test that get_type_from_spec normalizes type to lowercase for case-insensitive validation."""
129+
valid_keys = [NodeType.COMMAND, InternalNodeType.COMMAND]
130+
131+
test_cases = [
132+
({"type": "command"}, "command"), # lowercase
133+
({"type": "Command"}, "command"), # uppercase - should normalize to lowercase
134+
({"type": "CommandComponent"}, "CommandComponent"), # remains unchanged as it's not in NodeType
135+
]
136+
137+
for data, expected in test_cases:
138+
result = get_type_from_spec(data, valid_keys=valid_keys)
139+
assert result == expected

0 commit comments

Comments
 (0)