From c5fad9ff3ff7f5afbe7db55c3be2cb412eadadc8 Mon Sep 17 00:00:00 2001 From: MilesHolland <108901744+MilesHolland@users.noreply.github.com> Date: Thu, 20 Oct 2022 15:56:28 -0400 Subject: [PATCH] Re-arrange imports and experimental tags to prevent warnings on unrelated operations (#26892) * change imports to avoid extra experimental warnings * add tag to merged functon * cl * add experimental tag to registry property --- sdk/ml/azure-ai-ml/CHANGELOG.md | 1 + sdk/ml/azure-ai-ml/azure/ai/ml/_ml_client.py | 2 ++ .../azure-ai-ml/azure/ai/ml/entities/_registry/registry.py | 5 ++++- .../azure/ai/ml/operations/_registry_operations.py | 5 ++++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sdk/ml/azure-ai-ml/CHANGELOG.md b/sdk/ml/azure-ai-ml/CHANGELOG.md index bdef0df024a3..edd8ea1f8005 100644 --- a/sdk/ml/azure-ai-ml/CHANGELOG.md +++ b/sdk/ml/azure-ai-ml/CHANGELOG.md @@ -11,6 +11,7 @@ ### Bugs Fixed - MLClient.from_config can now find the default config.json on Compute Instance when running sample notebooks. +- Adjust registry experimental tags and imports to avoid warning printouts for unrelated operations. ### Other Changes diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/_ml_client.py b/sdk/ml/azure-ai-ml/azure/ai/ml/_ml_client.py index bbc7d7d8a1cd..38aaf3170b04 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/_ml_client.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/_ml_client.py @@ -32,6 +32,7 @@ from azure.ai.ml._restclient.v2022_10_01 import AzureMachineLearningWorkspaces as ServiceClient102022 from azure.ai.ml._scope_dependent_operations import OperationConfig, OperationsContainer, OperationScope from azure.ai.ml._user_agent import USER_AGENT +from azure.ai.ml._utils._experimental import experimental from azure.ai.ml._utils._http_utils import HttpPipeline from azure.ai.ml._utils._registry_utils import RegistryDiscovery from azure.ai.ml._utils.utils import _is_https_url, _validate_missing_sub_or_rg_and_raise @@ -562,6 +563,7 @@ def workspaces(self) -> WorkspaceOperations: return self._workspaces @property + @experimental def registries(self) -> RegistryOperations: """A collection of registry-related operations. diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_registry/registry.py b/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_registry/registry.py index 781a7d52274b..9135461c4a56 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_registry/registry.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_registry/registry.py @@ -14,7 +14,6 @@ ) from azure.ai.ml._restclient.v2022_10_01_preview.models import Registry as RestRegistry from azure.ai.ml._restclient.v2022_10_01_preview.models import RegistryProperties -from azure.ai.ml._schema.registry.registry import RegistrySchema from azure.ai.ml._utils.utils import dump_yaml_to_file from azure.ai.ml.constants._common import BASE_PATH_CONTEXT_KEY, PARAMS_OVERRIDE_KEY from azure.ai.ml.entities._credentials import IdentityConfiguration @@ -103,6 +102,8 @@ def dump( # represented by the registry API, which differs from how registries # are represented in YAML. This function converts those differences. def _to_dict(self) -> Dict: + # JIT import to avoid experimental warnings on unrelated calls + from azure.ai.ml._schema.registry.registry import RegistrySchema # pylint: disable=no-member schema = RegistrySchema(context={BASE_PATH_CONTEXT_KEY: "./"}) @@ -142,6 +143,8 @@ def _load( BASE_PATH_CONTEXT_KEY: Path(yaml_path).parent if yaml_path else Path("./"), PARAMS_OVERRIDE_KEY: params_override, } + # JIT import to avoid experimental warnings on unrelated calls + from azure.ai.ml._schema.registry.registry import RegistrySchema loaded_schema = load_from_dict(RegistrySchema, data, context, **kwargs) cls._convert_yaml_dict_to_entity_input(loaded_schema) return Registry(**loaded_schema) diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_registry_operations.py b/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_registry_operations.py index 49223c2361cd..fb6139a5ed61 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_registry_operations.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_registry_operations.py @@ -24,7 +24,6 @@ ops_logger = OpsLogger(__name__) module_logger = ops_logger.module_logger -@experimental class RegistryOperations: """RegistryOperations. @@ -51,6 +50,7 @@ def __init__( self.containerRegistry = "none" self._init_kwargs = kwargs + @experimental #@ monitor_with_activity(logger, "Registry.List", ActivityType.PUBLICAPI) def list(self, *, scope: str = Scope.RESOURCE_GROUP) -> Iterable[Registry]: """List all registries that the user has access to in the current @@ -68,6 +68,7 @@ def list(self, *, scope: str = Scope.RESOURCE_GROUP) -> Iterable[Registry]: return self._operation.list(cls=lambda objs: [Registry._from_rest_object(obj) for obj in objs], \ resource_group_name=self._resource_group_name) + @experimental # @monitor_with_activity(logger, "Registry.Get", ActivityType.PUBLICAPI) def get(self, name: str = None) -> Registry: """Get a registry by name. @@ -108,6 +109,7 @@ def _get_polling(self, name): path_format_arguments=path_format_arguments, ) + @experimental # @monitor_with_activity(logger, "Registry.BeginCreate", ActivityType.PUBLICAPI) def begin_create( self, @@ -136,6 +138,7 @@ def begin_create( return poller + @experimental # @monitor_with_activity(logger, "Registry.Delete", ActivityType.PUBLICAPI) def delete(self, *, name: str, **kwargs: Dict) -> None: """Delete a registry. Returns nothing on a successful operation.