Skip to content

Commit d96c2a3

Browse files
authored
AzureML: Fix ARM ID for registry environments (Azure#27305)
* Fix ARM id retrieval for registry environments * Update changelog * Update test_operation_orchestrator.py
1 parent 118e99f commit d96c2a3

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- Adjust registry experimental tags and imports to avoid warning printouts for unrelated operations.
1818
- Make registry delete operation return an LROPoller, and change name to begin_delete.
1919
- Prevent registering an already existing environment that references conda file.
20+
- Fix ARM id logic for registry environments (ex: Creating a registry component that references a registry environment).
2021

2122
### Other Changes
2223

sdk/ml/azure-ai-ml/azure/ai/ml/operations/_operation_orchestrator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
AzureMLResourceType,
4141
LABELLED_RESOURCE_ID_FORMAT,
4242
DEFAULT_LABEL_NAME,
43+
REGISTRY_VERSION_PATTERN
4344
)
4445
from azure.ai.ml.entities import Component
4546
from azure.ai.ml.entities._assets import Code, Data, Environment, Model
@@ -141,7 +142,7 @@ def get_asset_arm_id(
141142
# CLI strips off azureml: in the schema, appending it back as required by backend
142143
if (
143144
azureml_type == "environments"
144-
and asset.startswith(CURATED_ENV_PREFIX)
145+
and (asset.startswith(CURATED_ENV_PREFIX) or re.match(REGISTRY_VERSION_PATTERN, f"azureml:{asset}"))
145146
):
146147
return f"azureml:{asset}"
147148

@@ -181,7 +182,7 @@ def get_asset_arm_id(
181182
"Use fully qualified name to reference custom environments "
182183
"when creating assets in registry. "
183184
"The syntax for fully qualified names is "
184-
"azureml:registries/azureml/environments/{{env-name}}/versions/{{version}}"
185+
"azureml://registries/azureml/environments/{{env-name}}/versions/{{version}}"
185186
)
186187
raise ValidationException(
187188
message=msg.format(asset, azureml_type),

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ def create_yaml_inline_model(tmp_path: Path, resource_group_name: str) -> Path:
186186
@pytest.mark.unittest
187187
@pytest.mark.core_sdk_test
188188
class TestOperationOrchestration:
189+
def test_registry_environment(self, operation_orchestrator: OperationOrchestrator) -> None:
190+
test_input = '//registries/mafong-registry/environments/conda_name_version_e2e/versions/1.0.2'
191+
expected = 'azureml://registries/mafong-registry/environments/conda_name_version_e2e/versions/1.0.2'
192+
actual = operation_orchestrator.get_asset_arm_id(test_input, azureml_type=AzureMLResourceType.ENVIRONMENT)
193+
assert actual == expected
194+
189195
def test_code_arm_id(self, operation_orchestrator: OperationOrchestrator) -> None:
190196
code = VERSIONED_RESOURCE_ID_FORMAT.format(
191197
Test_Subscription,

0 commit comments

Comments
 (0)