diff --git a/sdk/ml/azure-ai-ml/CHANGELOG.md b/sdk/ml/azure-ai-ml/CHANGELOG.md index c3a3a14f2a3b..385b51093346 100644 --- a/sdk/ml/azure-ai-ml/CHANGELOG.md +++ b/sdk/ml/azure-ai-ml/CHANGELOG.md @@ -3,7 +3,7 @@ ## 0.2.0 (Unreleased) ### Features Added - + - Most configuration classes from the entity package now implement the standard mapping protocol. ### Breaking Changes ### Bugs Fixed @@ -15,7 +15,7 @@ - Dropped support for Python 3.6. The Python versions supported for this release are 3.7-3.10. ### Features Added - + ### Breaking Changes - OnlineDeploymentOperations.delete has been renamed to begin_delete. - Datastore credentials are switched to use unified credential configuration classes. diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_compute/compute_instance.py b/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_compute/compute_instance.py index 85978b6a9821..2eb0a8188841 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_compute/compute_instance.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_compute/compute_instance.py @@ -20,6 +20,7 @@ from azure.ai.ml.constants._common import BASE_PATH_CONTEXT_KEY, TYPE from azure.ai.ml.constants._compute import ComputeDefaults, ComputeType from azure.ai.ml.entities._compute.compute import Compute, NetworkSettings +from azure.ai.ml.entities._mixins import DictMixin from azure.ai.ml.entities._util import load_from_dict from azure.ai.ml.exceptions import ErrorCategory, ErrorTarget, ValidationException from azure.ai.ml.entities._credentials import IdentityConfiguration @@ -70,7 +71,7 @@ def ssh_port(self) -> str: return self._ssh_port -class AssignedUserConfiguration: +class AssignedUserConfiguration(DictMixin): """Settings to create a compute on behalf of another user.""" def __init__(self, *, user_tenant_id: str, user_object_id: str): diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_deployment/code_configuration.py b/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_deployment/code_configuration.py index b09dacb52283..3fc3da9f272b 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_deployment/code_configuration.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_deployment/code_configuration.py @@ -6,12 +6,13 @@ from azure.ai.ml._restclient.v2021_10_01.models import CodeConfiguration as RestCodeConfiguration from azure.ai.ml.entities._assets import Code +from azure.ai.ml.entities._mixins import DictMixin from azure.ai.ml.exceptions import ErrorCategory, ErrorTarget, ValidationException module_logger = logging.getLogger(__name__) -class CodeConfiguration: +class CodeConfiguration(DictMixin): """CodeConfiguration. :param code: Code entity, defaults to None diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/pipeline/_io.py b/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/pipeline/_io.py index fe57e1f71948..1c080373355f 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/pipeline/_io.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/pipeline/_io.py @@ -170,6 +170,9 @@ def _data_binding(self) -> str: """Return data binding string representation for this input/output.""" raise NotImplementedError() + # Why did we have this function? It prevents the DictMixin from being applied. + # Unclear if we explicitly do NOT want the mapping protocol to be applied to this, or it this was just + # confirmation that it didn't at the time. def keys(self): # This property is introduced to raise catchable Exception in marshmallow mapping validation trial. raise TypeError(f"'{type(self).__name__}' object is not a mapping") diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_mixins.py b/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_mixins.py index 5ebf761d2f8b..eee003c3a8f4 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_mixins.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_mixins.py @@ -17,6 +17,12 @@ def _from_rest_object(cls, obj: Any) -> Any: class DictMixin(object): + def __contains__(self, item): + return self.__dict__.__contains__(item) + + def __iter__(self): + return self.__dict__.__iter__() + def __setitem__(self, key, item): # type: (Any, Any) -> None self.__dict__[key] = item