Skip to content

Commit

Permalink
Registry SDK changes for get/list/create operations (Azure#26448)
Browse files Browse the repository at this point in the history
* Implement registry creation in sdk

* Replace missing files from ADO migration

* Add additional unittest

* Print existing registries until UPDATE implemented

* regenerate 10-01-preview autorest with manual fix

* registry schema feedback changes

* Registry entity class yaml conversion fixes

* fix unit tests

* un-hardcode acr and storage configs

* Fix test setup

* spelling corrections

* correct invalid syntax

* more syntax corrections

* more robust conditionals in to/from rest functions

* Add recording files.

* Set e2e test to use recording.

* remove unused import

* Apply suggestions from code review

Co-authored-by: Neehar Duvvuri <[email protected]>

* display identity and sub-resource ids properly

* Code review changes.

* Code review edits.

* Test migrate to git logic.

* remove curses from code

* Update recording jsons.

* Missing param.

* Undo unintentionally committed edit.

* Delete underscores from registry name.

* Correct yaml format.

* add yaml ref link and fix test registry yaml

* Update recordings

* fix last unit test

* add experimental tag everywhere

* add back in short circuit to create and update tests

* Code review edits.

* Do not handle existing registries differently.

* Change identity class to reference _credentials.

* make sdk and cli registries be a bit more similar

* publicize registry constants

* actually do what I said, and remove unnessessarily public constant

* Address pylint errors.

* Additional pylint errors.

* Additional pylint errors.

* Additional pylint.

* Revert deleted param.

Co-authored-by: Georgia Fitzgerald <[email protected]>
Co-authored-by: gfitzgerald42 <[email protected]>
Co-authored-by: Neehar Duvvuri <[email protected]>
  • Loading branch information
4 people authored Oct 3, 2022
1 parent 7956455 commit cfb56f4
Show file tree
Hide file tree
Showing 112 changed files with 5,552 additions and 4,623 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@
from copy import deepcopy
from typing import TYPE_CHECKING

from azure.mgmt.core import ARMPipelineClient
from msrest import Deserializer, Serializer

from azure.mgmt.core import ARMPipelineClient

from . import models
from ._configuration import AzureMachineLearningWorkspacesConfiguration
from .operations import BatchDeploymentsOperations, BatchEndpointsOperations, CodeContainersOperations, CodeVersionsOperations, ComponentContainersOperations, ComponentVersionsOperations, ComputeOperations, DataContainersOperations, DataVersionsOperations, DatastoresOperations, EnvironmentContainersOperations, EnvironmentVersionsOperations, JobsOperations, LabelingJobsOperations, ModelContainersOperations, ModelVersionsOperations, OnlineDeploymentsOperations, OnlineEndpointsOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QuotasOperations, RegistriesOperations, RegistryCodeContainersOperations, RegistryCodeVersionsOperations, RegistryComponentContainersOperations, RegistryComponentVersionsOperations, RegistryEnvironmentContainersOperations, RegistryEnvironmentVersionsOperations, RegistryModelContainersOperations, RegistryModelVersionsOperations, SchedulesOperations, UsagesOperations, VirtualMachineSizesOperations, WorkspaceConnectionsOperations, WorkspaceFeaturesOperations, WorkspacesOperations

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Optional
from typing import Any

from azure.core.credentials import TokenCredential
from azure.core.rest import HttpRequest, HttpResponse

class AzureMachineLearningWorkspaces(object):
class AzureMachineLearningWorkspaces(object): # pylint: disable=too-many-instance-attributes
"""These APIs allow end users to operate on Azure Machine Learning Workspace resources.
:ivar operations: Operations operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from azure.core.credentials import TokenCredential


class AzureMachineLearningWorkspacesConfiguration(Configuration):
class AzureMachineLearningWorkspacesConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for AzureMachineLearningWorkspaces.
Note that all parameters used to create this instance are saved as instance
Expand All @@ -31,7 +31,8 @@ class AzureMachineLearningWorkspacesConfiguration(Configuration):
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription.
:type subscription_id: str
:keyword api_version: Api Version. The default value is "2022-10-01-preview". Note that overriding this default value may result in unsupported behavior.
:keyword api_version: Api Version. The default value is "2022-10-01-preview". Note that
overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
# --------------------------------------------------------------------------

from copy import deepcopy
from typing import Any, Awaitable, Optional, TYPE_CHECKING
from typing import Any, Awaitable, TYPE_CHECKING

from msrest import Deserializer, Serializer

from azure.core.rest import AsyncHttpResponse, HttpRequest
from azure.mgmt.core import AsyncARMPipelineClient
from msrest import Deserializer, Serializer

from .. import models
from ._configuration import AzureMachineLearningWorkspacesConfiguration
Expand All @@ -21,7 +22,7 @@
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential

class AzureMachineLearningWorkspaces:
class AzureMachineLearningWorkspaces: # pylint: disable=too-many-instance-attributes
"""These APIs allow end users to operate on Azure Machine Learning Workspace resources.
:ivar operations: Operations operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from azure.core.credentials_async import AsyncTokenCredential


class AzureMachineLearningWorkspacesConfiguration(Configuration):
class AzureMachineLearningWorkspacesConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for AzureMachineLearningWorkspaces.
Note that all parameters used to create this instance are saved as instance
Expand All @@ -29,7 +29,8 @@ class AzureMachineLearningWorkspacesConfiguration(Configuration):
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the target subscription.
:type subscription_id: str
:keyword api_version: Api Version. The default value is "2022-10-01-preview". Note that overriding this default value may result in unsupported behavior.
:keyword api_version: Api Version. The default value is "2022-10-01-preview". Note that
overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# pylint: disable=too-many-lines
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
import functools
from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union
import warnings
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union

from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
Expand Down Expand Up @@ -75,9 +74,6 @@ def list(
:type top: int
:param skip: Continuation token for pagination.
:type skip: str
:keyword api_version: Api Version. The default value is "2022-10-01-preview". Note that
overriding this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either BatchDeploymentTrackedResourceArmPaginatedResult
or the result of cls(response)
Expand Down Expand Up @@ -137,7 +133,11 @@ async def extract_data(pipeline_response):
async def get_next(next_link=None):
request = prepare_request(next_link)

pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access
request,
stream=False,
**kwargs
)
response = pipeline_response.http_response

if response.status_code not in [200]:
Expand All @@ -151,9 +151,9 @@ async def get_next(next_link=None):
return AsyncItemPaged(
get_next, extract_data
)
list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/batchEndpoints/{endpointName}/deployments'} # type: ignore
list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/batchEndpoints/{endpointName}/deployments"} # type: ignore

async def _delete_initial(
async def _delete_initial( # pylint: disable=inconsistent-return-statements
self,
resource_group_name: str,
workspace_name: str,
Expand Down Expand Up @@ -182,7 +182,11 @@ async def _delete_initial(
request = _convert_request(request)
request.url = self._client.format_url(request.url)

pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access
request,
stream=False,
**kwargs
)
response = pipeline_response.http_response

if response.status_code not in [200, 202, 204]:
Expand All @@ -199,11 +203,11 @@ async def _delete_initial(
if cls:
return cls(pipeline_response, None, response_headers)

_delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/batchEndpoints/{endpointName}/deployments/{deploymentName}'} # type: ignore
_delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/batchEndpoints/{endpointName}/deployments/{deploymentName}"} # type: ignore


@distributed_trace_async
async def begin_delete(
async def begin_delete( # pylint: disable=inconsistent-return-statements
self,
resource_group_name: str,
workspace_name: str,
Expand All @@ -223,9 +227,6 @@ async def begin_delete(
:type endpoint_name: str
:param deployment_name: Inference deployment identifier.
:type deployment_name: str
:keyword api_version: Api Version. The default value is "2022-10-01-preview". Note that
overriding this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
Expand All @@ -239,7 +240,7 @@ async def begin_delete(
:raises: ~azure.core.exceptions.HttpResponseError
"""
api_version = kwargs.pop('api_version', "2022-10-01-preview") # type: str
polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod]
polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod]
cls = kwargs.pop('cls', None) # type: ClsType[None]
lro_delay = kwargs.pop(
'polling_interval',
Expand Down Expand Up @@ -273,10 +274,9 @@ def get_long_running_output(pipeline_response):
client=self._client,
deserialization_callback=get_long_running_output
)
else:
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method)

begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/batchEndpoints/{endpointName}/deployments/{deploymentName}'} # type: ignore
begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/batchEndpoints/{endpointName}/deployments/{deploymentName}"} # type: ignore

@distributed_trace_async
async def get(
Expand All @@ -299,9 +299,6 @@ async def get(
:type endpoint_name: str
:param deployment_name: The identifier for the Batch deployments.
:type deployment_name: str
:keyword api_version: Api Version. The default value is "2022-10-01-preview". Note that
overriding this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: BatchDeployment, or the result of cls(response)
:rtype: ~azure.mgmt.machinelearningservices.models.BatchDeployment
Expand All @@ -328,7 +325,11 @@ async def get(
request = _convert_request(request)
request.url = self._client.format_url(request.url)

pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access
request,
stream=False,
**kwargs
)
response = pipeline_response.http_response

if response.status_code not in [200]:
Expand All @@ -343,7 +344,7 @@ async def get(

return deserialized

get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/batchEndpoints/{endpointName}/deployments/{deploymentName}'} # type: ignore
get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/batchEndpoints/{endpointName}/deployments/{deploymentName}"} # type: ignore


async def _update_initial(
Expand Down Expand Up @@ -380,7 +381,11 @@ async def _update_initial(
request = _convert_request(request)
request.url = self._client.format_url(request.url)

pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access
request,
stream=False,
**kwargs
)
response = pipeline_response.http_response

if response.status_code not in [200, 202]:
Expand All @@ -403,7 +408,7 @@ async def _update_initial(

return deserialized

_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/batchEndpoints/{endpointName}/deployments/{deploymentName}'} # type: ignore
_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/batchEndpoints/{endpointName}/deployments/{deploymentName}"} # type: ignore


@distributed_trace_async
Expand Down Expand Up @@ -431,9 +436,6 @@ async def begin_update(
:param body: Batch inference deployment definition object.
:type body:
~azure.mgmt.machinelearningservices.models.PartialBatchDeploymentPartialMinimalTrackedResourceWithProperties
:keyword api_version: Api Version. The default value is "2022-10-01-preview". Note that
overriding this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
Expand All @@ -450,7 +452,7 @@ async def begin_update(
"""
api_version = kwargs.pop('api_version', "2022-10-01-preview") # type: str
content_type = kwargs.pop('content_type', "application/json") # type: Optional[str]
polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod]
polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod]
cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchDeployment"]
lro_delay = kwargs.pop(
'polling_interval',
Expand Down Expand Up @@ -489,10 +491,9 @@ def get_long_running_output(pipeline_response):
client=self._client,
deserialization_callback=get_long_running_output
)
else:
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method)

begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/batchEndpoints/{endpointName}/deployments/{deploymentName}'} # type: ignore
begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/batchEndpoints/{endpointName}/deployments/{deploymentName}"} # type: ignore

async def _create_or_update_initial(
self,
Expand Down Expand Up @@ -528,7 +529,11 @@ async def _create_or_update_initial(
request = _convert_request(request)
request.url = self._client.format_url(request.url)

pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access
request,
stream=False,
**kwargs
)
response = pipeline_response.http_response

if response.status_code not in [200, 201]:
Expand All @@ -550,7 +555,7 @@ async def _create_or_update_initial(

return deserialized

_create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/batchEndpoints/{endpointName}/deployments/{deploymentName}'} # type: ignore
_create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/batchEndpoints/{endpointName}/deployments/{deploymentName}"} # type: ignore


@distributed_trace_async
Expand All @@ -577,9 +582,6 @@ async def begin_create_or_update(
:type deployment_name: str
:param body: Batch inference deployment definition object.
:type body: ~azure.mgmt.machinelearningservices.models.BatchDeployment
:keyword api_version: Api Version. The default value is "2022-10-01-preview". Note that
overriding this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
Expand All @@ -596,7 +598,7 @@ async def begin_create_or_update(
"""
api_version = kwargs.pop('api_version', "2022-10-01-preview") # type: str
content_type = kwargs.pop('content_type', "application/json") # type: Optional[str]
polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod]
polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod]
cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchDeployment"]
lro_delay = kwargs.pop(
'polling_interval',
Expand Down Expand Up @@ -635,7 +637,6 @@ def get_long_running_output(pipeline_response):
client=self._client,
deserialization_callback=get_long_running_output
)
else:
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method)

begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/batchEndpoints/{endpointName}/deployments/{deploymentName}'} # type: ignore
begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/batchEndpoints/{endpointName}/deployments/{deploymentName}"} # type: ignore
Loading

0 comments on commit cfb56f4

Please sign in to comment.