Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sdk/ml/azure-ai-ml/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Release History
## 1.26.0 (unreleased)

### Bugs Fixed
- #37464 - Allowing to update a component in register with anonymousEnvironment environment.

## 1.25.0 (2025-02-11)

### Features Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,15 @@ def create_or_update(self, environment: Environment) -> Environment: # type: ig
),
)

environment = _check_and_upload_env_build_context(
environment=environment,
operations=self,
sas_uri=sas_uri,
show_progress=self._show_progress,
)
# upload only in case of when its not registry
# or successfully acquire sas_uri
if not self._registry_name or sas_uri:
environment = _check_and_upload_env_build_context(
environment=environment,
operations=self,
sas_uri=sas_uri,
show_progress=self._show_progress,
)
env_version_resource = environment._to_rest_object()
env_rest_obj = (
self._version_operations.begin_create_or_update(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,11 @@ def test_get_no_version(self, mock_environment_operation: EnvironmentOperations)

def test_create_or_update(self, mock_environment_operation: EnvironmentOperations) -> None:
env = load_environment(source="./tests/test_configs/environment/environment_conda.yml")
with patch("azure.ai.ml.operations._environment_operations.Environment._from_rest_object", return_value=None):
with patch(
"azure.ai.ml.operations._environment_operations.Environment._from_rest_object", return_value=None
), patch("azure.ai.ml.operations._environment_operations._check_and_upload_env_build_context") as check_upload:
_ = mock_environment_operation.create_or_update(env)
check_upload.assert_called_once()
mock_environment_operation._version_operations.create_or_update.assert_called_once()

def test_create_autoincrement(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@

import pytest

from azure.ai.ml._restclient.v2022_05_01.models import (
EnvironmentVersionData,
EnvironmentVersionDetails,
)

from azure.ai.ml import load_environment
from azure.ai.ml._restclient.v2022_05_01.models import EnvironmentVersionData, EnvironmentVersionDetails
from azure.ai.ml._scope_dependent_operations import OperationConfig, OperationScope
from azure.ai.ml.operations import EnvironmentOperations
from azure.ai.ml import load_environment


@pytest.fixture
Expand Down Expand Up @@ -58,3 +54,27 @@ def test_restore_version(self, mock_environment_operation: EnvironmentOperations
body=env_version,
resource_group_name=mock_environment_operation._resource_group_name,
)

def test_create_or_update_sas_uri_success(self, mock_environment_operation: EnvironmentOperations):
env = load_environment(source="./tests/test_configs/environment/environment_conda.yml")
with patch(
"azure.ai.ml.operations._environment_operations.Environment._from_rest_object", return_value=None
), patch(
"azure.ai.ml.operations._environment_operations.get_sas_uri_for_registry_asset", return_value="some_sas_uri"
), patch(
"azure.ai.ml.operations._environment_operations._check_and_upload_env_build_context"
) as check_upload:
mock_environment_operation.create_or_update(env)
check_upload.assert_called_once()

def test_create_or_update_sas_uri_failure(self, mock_environment_operation: EnvironmentOperations):
env = load_environment(source="./tests/test_configs/environment/environment_conda.yml")
with patch(
"azure.ai.ml.operations._environment_operations.Environment._from_rest_object", return_value=None
), patch(
"azure.ai.ml.operations._environment_operations.get_sas_uri_for_registry_asset", return_value=None
), patch(
"azure.ai.ml.operations._environment_operations._check_and_upload_env_build_context"
) as check_upload:
mock_environment_operation.create_or_update(env)
check_upload.assert_not_called()