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
6 changes: 6 additions & 0 deletions sdk/ml/azure-ai-ml/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
### Features Added

- Removed the dependencies - msrest and six
- Added support for `Deployment Templates` along with the following operations:
- `ml_client.deployment_templates.create_or_update()`
- `ml_client.deployment_templates.list()`
- `ml_client.deployment_templates.get()`
- `ml_client.deployment_templates.archive()`
- `ml_client.deployment_templates.restore()`

### Bugs Fixed
- Fix for registry resource group passed to OnlineEndpointOperations when model is in registry in different resource group compared to workspace.
Expand Down
2 changes: 2 additions & 0 deletions sdk/ml/azure-ai-ml/azure/ai/ml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
load_connection,
load_data,
load_datastore,
load_deployment_template,
load_environment,
load_feature_set,
load_feature_store,
Expand Down Expand Up @@ -67,6 +68,7 @@
"load_compute",
"load_data",
"load_datastore",
"load_deployment_template",
"load_feature_set",
"load_feature_store",
"load_feature_store_entity",
Expand Down
45 changes: 43 additions & 2 deletions sdk/ml/azure-ai-ml/azure/ai/ml/_ml_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,15 @@
from azure.ai.ml._restclient.v2024_01_01_preview import AzureMachineLearningWorkspaces as ServiceClient012024Preview
from azure.ai.ml._restclient.v2024_04_01_preview import AzureMachineLearningWorkspaces as ServiceClient042024Preview
from azure.ai.ml._restclient.v2024_07_01_preview import AzureMachineLearningWorkspaces as ServiceClient072024Preview
from azure.ai.ml._restclient.v2024_10_01_preview import AzureMachineLearningWorkspaces as ServiceClient102024Preview
from azure.ai.ml._restclient.v2025_01_01_preview import AzureMachineLearningWorkspaces as ServiceClient012025Preview
from azure.ai.ml._restclient.v2024_10_01_preview import (
AzureMachineLearningWorkspaces as ServiceClient102024Preview,
)
from azure.ai.ml._restclient.v2025_01_01_preview import (
AzureMachineLearningWorkspaces as ServiceClient012025Preview,
)
from azure.ai.ml._restclient.v2024_04_01_dataplanepreview import (
AzureMachineLearningWorkspaces as ServiceClient042024DataPlanePreview,
)
from azure.ai.ml._restclient.workspace_dataplane import (
AzureMachineLearningWorkspaces as ServiceClientWorkspaceDataplane,
)
Expand All @@ -59,6 +66,7 @@
Component,
Compute,
Datastore,
DeploymentTemplate,
Environment,
Index,
Job,
Expand All @@ -84,6 +92,7 @@
ComputeOperations,
DataOperations,
DatastoreOperations,
DeploymentTemplateOperations,
EnvironmentOperations,
EvaluatorOperations,
IndexOperations,
Expand Down Expand Up @@ -377,6 +386,13 @@ def __init__(
**kwargs,
)

self._service_client_04_2024_dataplanepreview = ServiceClient042024DataPlanePreview(
credential=self._credential,
subscription_id=self._operation_scope._subscription_id,
base_url=base_url,
**kwargs,
)

self._service_client_07_2024_preview = ServiceClient072024Preview(
credential=self._credential,
subscription_id=(
Expand Down Expand Up @@ -668,6 +684,14 @@ def __init__(
)
self._operation_container.add(AzureMLResourceType.ONLINE_DEPLOYMENT, self._online_deployments)
self._operation_container.add(AzureMLResourceType.BATCH_DEPLOYMENT, self._batch_deployments)

self._deployment_templates = DeploymentTemplateOperations(
self._operation_scope,
self._operation_config,
self._service_client_04_2024_dataplanepreview,
**ops_kwargs,
)

self._data = DataOperations(
self._ws_operation_scope if registry_reference else self._operation_scope,
self._operation_config,
Expand Down Expand Up @@ -1074,6 +1098,16 @@ def batch_deployments(self) -> BatchDeploymentOperations:
"""
return self._batch_deployments

@property
@experimental
def deployment_templates(self) -> DeploymentTemplateOperations:
"""A collection of deployment template related operations.

:return: Deployment Template operations.
:rtype: ~azure.ai.ml.operations.DeploymentTemplateOperations
"""
return self._deployment_templates

@property
def datastores(self) -> DatastoreOperations:
"""A collection of datastore related operations.
Expand Down Expand Up @@ -1454,3 +1488,10 @@ def _(entity: ServerlessEndpoint, operations, *args, **kwargs):
def _(entity: MarketplaceSubscription, operations, *args, **kwargs):
module_logger.debug("Creating or updating marketplace subscriptions")
return operations[AzureMLResourceType.MARKETPLACE_SUBSCRIPTION].begin_create_or_update(entity, **kwargs)


@_begin_create_or_update.register(DeploymentTemplate)
def _(entity: DeploymentTemplate, operations, *args, **kwargs):
module_logger.debug("Creating or updating capability hosts")

return operations[AzureMLResourceType.DEPLOYMENT_TEMPLATE].begin_create_or_update(entity, **kwargs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.
# --------------------------------------------------------------------------

from ._azure_machine_learning_workspaces import AzureMachineLearningWorkspaces
from ._version import VERSION

__version__ = VERSION
__all__ = ['AzureMachineLearningWorkspaces']

# `._patch.py` is used for handwritten extensions to the generated code
# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
from ._patch import patch_sdk
patch_sdk()
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# 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.
# --------------------------------------------------------------------------

from copy import deepcopy
from typing import TYPE_CHECKING

from msrest import Deserializer, Serializer

from azure.mgmt.core import ARMPipelineClient

from . import models
from ._configuration import AzureMachineLearningWorkspacesConfiguration
from .operations import DeploymentTemplatesOperations, IndexesOperations

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

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

class AzureMachineLearningWorkspaces(object):
"""AzureMachineLearningWorkspaces.

:ivar deployment_templates: DeploymentTemplatesOperations operations
:vartype deployment_templates:
azure.mgmt.machinelearningservices.operations.DeploymentTemplatesOperations
:ivar indexes: IndexesOperations operations
:vartype indexes: azure.mgmt.machinelearningservices.operations.IndexesOperations
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:keyword api_version: Api Version. The default value is "2024-04-01-preview". Note that
overriding this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
"""

def __init__(
self,
credential, # type: "TokenCredential"
**kwargs # type: Any
):
# type: (...) -> None
_base_url = '{endpoint}/genericasset/v2.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices'
self._config = AzureMachineLearningWorkspacesConfiguration(credential=credential, **kwargs)
# Remove base_url from kwargs to avoid conflict, then pass as positional argument
kwargs_copy = kwargs.copy()
kwargs_copy.pop('base_url', None)
self._client = ARMPipelineClient(_base_url, config=self._config, **kwargs_copy)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.deployment_templates = DeploymentTemplatesOperations(self._client, self._config, self._serialize, self._deserialize)
self.indexes = IndexesOperations(self._client, self._config, self._serialize, self._deserialize)


def _send_request(
self,
request, # type: HttpRequest
**kwargs # type: Any
):
# type: (...) -> HttpResponse
"""Runs the network request through the client's chained policies.

>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client._send_request(request)
<HttpResponse: 200 OK>

For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.HttpResponse
"""

request_copy = deepcopy(request)
request_copy.url = self._client.format_url(request_copy.url)
return self._client.send_request(request_copy, **kwargs)

def close(self):
# type: () -> None
self._client.close()

def __enter__(self):
# type: () -> AzureMachineLearningWorkspaces
self._client.__enter__()
return self

def __exit__(self, *exc_details):
# type: (Any) -> None
self._client.__exit__(*exc_details)
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 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.
# --------------------------------------------------------------------------

from typing import TYPE_CHECKING

from azure.core.configuration import Configuration
from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy

from ._version import VERSION

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

from azure.core.credentials import TokenCredential


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
attributes.

:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:keyword api_version: Api Version. The default value is "2024-04-01-preview". Note that
overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(
self,
credential, # type: "TokenCredential"
**kwargs # type: Any
):
# type: (...) -> None
super(AzureMachineLearningWorkspacesConfiguration, self).__init__(**kwargs)
api_version = kwargs.pop('api_version', "2024-04-01-preview") # type: str

if credential is None:
raise ValueError("Parameter 'credential' must not be None.")

self.credential = credential
self.api_version = api_version
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
kwargs.setdefault('sdk_moniker', 'mgmt-machinelearningservices/{}'.format(VERSION))
self._configure(**kwargs)

def _configure(
self,
**kwargs # type: Any
):
# type: (...) -> None
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
if self.credential and not self.authentication_policy:
self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# coding=utf-8
# --------------------------------------------------------------------------
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the ""Software""), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
# --------------------------------------------------------------------------

# This file is used for handwritten extensions to the generated code. Example:
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
def patch_sdk():
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# --------------------------------------------------------------------------
# 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.
# --------------------------------------------------------------------------

from azure.core.pipeline.transport import HttpRequest

def _convert_request(request, files=None):
data = request.content if not files else None
request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data)
if files:
request.set_formdata_body(files)
return request

def _format_url_section(template, **kwargs):
components = template.split("/")
while components:
try:
return template.format(**kwargs)
except KeyError as key:
formatted_components = template.split("/")
components = [
c for c in formatted_components if "{}".format(key.args[0]) not in c
]
template = "/".join(components)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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.
# --------------------------------------------------------------------------

VERSION = "0.1.0"
Loading