Skip to content

Commit 6ee894c

Browse files
needuviscai-msft
andauthored
[ML] Serverless Endpoints (#34474)
* serverless endpoints base code * add endpoint entity for serverless * wire up curated class * keyword only constructor * disable pylint for unused argument * wip * validation basic passing * add support for marketplace subscriptions * add overriden marketplacesub * clean up error message * linting errors * clean up type hint * lint * make new entities public, fix an issue with marketplace ops * run black * remove test script from directory * deleted file * fix issues based on testing for get, list, list_keys based on CLI testing * fix marketplace issues based on CLI testing * clean up load functions * create from CLI working for marketplace subs * fix impl of regenerate keys * remove unused serverless_endpoint file * add **kwargs passthrough to operation methods * add back experimental import * add telemetry logging for serverless endpoints * marketplace sub telemetry * add scoring uri to deserialized response * make docstrings work, make sure all entities are public and experimental * make system data dumpable * add headers to response * fix docstrings for headers * fix up some docstrings * fix pylint issues * run black on files * fix mypy errors * run black again * spellcheck * address last pylint issues * run black --------- Co-authored-by: iscai-msft <[email protected]>
1 parent c077d64 commit 6ee894c

File tree

18 files changed

+3640
-0
lines changed

18 files changed

+3640
-0
lines changed

.vscode/cspell.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@
100100
"sdk/ml/azure-ai-ml/swagger/**",
101101
"sdk/ml/azure-ai-ml/NOTICE.txt",
102102
"sdk/ml/azure-ai-ml/.pre-commit-config.yaml",
103+
"sdk/ml/azure-ai-ml/azure/ai/ml/entities/_autogen_entities/_model_base.py",
104+
"sdk/ml/azure-ai-ml/azure/ai/ml/entities/_autogen_entities/_serialization.py",
103105
"sdk/monitor/azure-monitor-opentelemetry/samples/tracing/django/sample/db.sqlite3",
104106
"sdk/monitor/azure-monitor-opentelemetry-exporter/samples/traces/django/sample/db.sqlite3",
105107
"sdk/loadtestservice/azure-developer-loadtesting/**",

sdk/ml/azure-ai-ml/azure/ai/ml/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828
load_feature_store,
2929
load_feature_store_entity,
3030
load_job,
31+
load_marketplace_subscription,
3132
load_model,
3233
load_model_package,
3334
load_online_deployment,
3435
load_online_endpoint,
36+
load_serverless_endpoint,
3537
load_registry,
3638
load_workspace,
3739
load_connection,
@@ -69,6 +71,8 @@
6971
"load_registry",
7072
"load_connection",
7173
"load_model_package",
74+
"load_marketplace_subscription",
75+
"load_serverless_endpoint",
7276
]
7377

7478
__version__ = VERSION

sdk/ml/azure-ai-ml/azure/ai/ml/_ml_client.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
from azure.ai.ml._utils._preflight_utils import get_deployments_operation
4949
from azure.ai.ml._utils._registry_utils import get_registry_client
5050
from azure.ai.ml._utils.utils import _is_https_url
51+
from azure.ai.ml._utils._experimental import experimental
5152
from azure.ai.ml.constants._common import AzureMLResourceType, DefaultOpenEncoding
5253
from azure.ai.ml.entities import (
5354
BatchDeployment,
@@ -66,6 +67,8 @@
6667
Registry,
6768
Schedule,
6869
Workspace,
70+
ServerlessEndpoint,
71+
MarketplaceSubscription,
6972
)
7073
from azure.ai.ml.entities._assets import WorkspaceAssetReference
7174
from azure.ai.ml.exceptions import ErrorCategory, ErrorTarget, ValidationException
@@ -85,6 +88,8 @@
8588
RegistryOperations,
8689
ConnectionsOperations,
8790
WorkspaceOperations,
91+
ServerlessEndpointOperations,
92+
MarketplaceSubscriptionOperations,
8893
)
8994
from azure.ai.ml.operations._code_operations import CodeOperations
9095
from azure.ai.ml.operations._feature_set_operations import FeatureSetOperations
@@ -682,9 +687,22 @@ def __init__(
682687
**ops_kwargs, # type: ignore[arg-type]
683688
)
684689

690+
self._serverless_endpoints = ServerlessEndpointOperations(
691+
self._operation_scope,
692+
self._operation_config,
693+
self._service_client_01_2024_preview,
694+
self._operation_container,
695+
)
696+
self._marketplace_subscriptions = MarketplaceSubscriptionOperations(
697+
self._operation_scope,
698+
self._operation_config,
699+
self._service_client_01_2024_preview,
700+
)
685701
self._operation_container.add(AzureMLResourceType.FEATURE_STORE, self._featurestores) # type: ignore[arg-type]
686702
self._operation_container.add(AzureMLResourceType.FEATURE_SET, self._featuresets)
687703
self._operation_container.add(AzureMLResourceType.FEATURE_STORE_ENTITY, self._featurestoreentities)
704+
self._operation_container.add(AzureMLResourceType.SERVERLESS_ENDPOINT, self._serverless_endpoints)
705+
self._operation_container.add(AzureMLResourceType.MARKETPLACE_SUBSCRIPTION, self._marketplace_subscriptions)
688706

689707
@classmethod
690708
def from_config(
@@ -996,6 +1014,25 @@ def schedules(self) -> ScheduleOperations:
9961014
return self._schedules
9971015

9981016
@property
1017+
@experimental
1018+
def serverless_endpoints(self) -> ServerlessEndpointOperations:
1019+
"""A collection of serverless endpoint related operations.
1020+
1021+
:return: Serverless endpoint operations.
1022+
:rtype: ~azure.ai.ml.operations.ServerlessEndpointOperations
1023+
"""
1024+
return self._serverless_endpoints
1025+
1026+
@property
1027+
@experimental
1028+
def marketplace_subscriptions(self) -> MarketplaceSubscriptionOperations:
1029+
"""A collection of marketplace subscription related operations.
1030+
1031+
:return: Marketplace subscription operations.
1032+
:rtype: ~azure.ai.ml.operations.MarketplaceSubscriptionOperations
1033+
"""
1034+
return self._marketplace_subscriptions
1035+
9991036
def indexes(self) -> IndexOperations:
10001037
"""A collection of index related operations.
10011038
@@ -1281,3 +1318,15 @@ def _(entity: PipelineComponentBatchDeployment, operations, *args, **kwargs):
12811318
def _(entity: Schedule, operations, *args, **kwargs):
12821319
module_logger.debug("Creating or updating schedules")
12831320
return operations[AzureMLResourceType.SCHEDULE].begin_create_or_update(entity, **kwargs)
1321+
1322+
1323+
@_begin_create_or_update.register(ServerlessEndpoint)
1324+
def _(entity: ServerlessEndpoint, operations, *args, **kwargs):
1325+
module_logger.debug("Creating or updating serverless endpoints")
1326+
return operations[AzureMLResourceType.SERVERLESS_ENDPOINT].begin_create_or_update(entity, **kwargs)
1327+
1328+
1329+
@_begin_create_or_update.register(MarketplaceSubscription)
1330+
def _(entity: MarketplaceSubscription, operations, *args, **kwargs):
1331+
module_logger.debug("Creating or updating marketplace subscriptions")
1332+
return operations[AzureMLResourceType.MARKETPLACE_SUBSCRIPTION].begin_create_or_update(entity, **kwargs)

sdk/ml/azure-ai-ml/azure/ai/ml/constants/_common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ class AzureMLResourceType:
270270
"""Hub resource type."""
271271
PROJECT = "project"
272272
"""Project resource type."""
273+
SERVERLESS_ENDPOINT = "serverless_endpoints"
274+
"""Serverless endpoint resource type."""
275+
MARKETPLACE_SUBSCRIPTION = "marketplace_subscriptions"
276+
"""Marketplace subscription resource type."""
273277
INDEX = "indexes"
274278
"""Index resource type."""
275279

sdk/ml/azure-ai-ml/azure/ai/ml/entities/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from ._assets.environment import BuildContext, Environment
4040
from ._assets.intellectual_property import IntellectualProperty
4141
from ._assets.workspace_asset_reference import WorkspaceAssetReference as WorkspaceModelReference
42+
from ._autogen_entities.models import MarketplaceSubscription, ServerlessEndpoint, MarketplacePlan
4243
from ._builders import Command, Parallel, Pipeline, Spark, Sweep
4344
from ._component.command_component import CommandComponent
4445
from ._component.component import Component
@@ -473,6 +474,9 @@
473474
"DeploymentCollection",
474475
"RequestLogging",
475476
"NoneCredentialConfiguration",
477+
"MarketplacePlan",
478+
"MarketplaceSubscription",
479+
"ServerlessEndpoint",
476480
"AccountKeyConfiguration",
477481
"AadCredentialConfiguration",
478482
"Index",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
10+
try:
11+
from ._patch import __all__ as _patch_all
12+
from ._patch import * # pylint: disable=unused-wildcard-import
13+
except ImportError:
14+
_patch_all = []
15+
from ._patch import patch_sdk as _patch_sdk
16+
17+
__all__ = []
18+
__all__.extend([p for p in _patch_all if p not in __all__])
19+
20+
_patch_sdk()

0 commit comments

Comments
 (0)