Skip to content

Commit 53df797

Browse files
HittherhodSam Rhody
andauthored
Update SDK to Support Serverless Custom VNet on Workspace Create and Update (Azure#32520)
* Added support for creating workspace with Serverless custom VNET and updating the settings of it * Removing Protocol (added in 3.8) to support Python 3.7 * Fixed tests * Updated Diagnosis deserialization to also account for updated API version * Addressing review comments and failing gates. Also bumping guidelines version to match global CI version --------- Co-authored-by: Sam Rhody <[email protected]>
1 parent a0a1018 commit 53df797

22 files changed

+560
-132
lines changed

sdk/ml/azure-ai-ml/.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ repos:
4343
dependencies = [
4444
(
4545
"azure-pylint-guidelines-checker",
46-
"0.1.0",
46+
"0.2.0",
4747
[
4848
"--index-url",
4949
"https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/",

sdk/ml/azure-ai-ml/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
### Features Added
2121
- Now, when you specify `delete_dependent_resources` as True when deleting a workspace, the log analytics resource
2222
associated with the workspace application insights resource will also be deleted.
23+
- Now, when creating or updating a workspace, you can provide a `serverless_compute` configuration object. This allows configuring a custom subnet in which all Serverless computes will be created. You can also specify whether or not these Serverless computes will have public IP addresses or not.
2324

2425
### Breaking Changes
2526
- [Python 3.7 reached end-of-life on June 27th 2023](https://devguide.python.org/versions/). Consequently, 3.7 will be deprecated in azure-ai-ml starting in October 2023 and azure-ai-ml will end support for 3.7 in February 2024.

sdk/ml/azure-ai-ml/azure/ai/ml/_arm_deployments/arm_templates/workspace_base.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,13 @@
553553
"metadata": {
554554
"description": "Resource Id of BYO open ai resource."
555555
}
556+
},
557+
"serverless_compute_settings": {
558+
"type": "object",
559+
"defaultValue": {},
560+
"metadata": {
561+
"description": "Serverless compute settings to be used for the workspace."
562+
}
556563
}
557564
},
558565
"variables": {
@@ -750,7 +757,7 @@
750757
{
751758
"condition": "[variables('enablePE')]",
752759
"type": "Microsoft.MachineLearningServices/workspaces",
753-
"apiVersion": "2023-04-01-preview",
760+
"apiVersion": "2023-08-01-preview",
754761
"tags": "[parameters('tagValues')]",
755762
"name": "[parameters('workspaceName')]",
756763
"kind": "[parameters('kind')]",
@@ -798,7 +805,8 @@
798805
"existingWorkspaces": "[parameters('existing_workspaces')]",
799806
"azureOpenAI": {
800807
"resourceId": "[parameters('byo_open_ai_resource_id')]"
801-
}
808+
},
809+
"serverlessComputeSettings": "[parameters('serverless_compute_settings')]"
802810
}
803811
},
804812
{

sdk/ml/azure-ai-ml/azure/ai/ml/_arm_deployments/arm_templates/workspace_param.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,5 +181,8 @@
181181
},
182182
"byo_open_ai_resource_id": {
183183
"value": ""
184+
},
185+
"serverless_compute_settings": {
186+
"value": {}
184187
}
185188
}

sdk/ml/azure-ai-ml/azure/ai/ml/_arm_deployments/arm_templates/workspace_project.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,13 @@
592592
"metadata": {
593593
"description": "Resource Id of BYO open ai resource."
594594
}
595+
},
596+
"serverless_compute_settings": {
597+
"type": "object",
598+
"defaultValue": {},
599+
"metadata": {
600+
"description": "Serverless compute configuration."
601+
}
595602
}
596603
},
597604
"variables": {
@@ -663,7 +670,7 @@
663670
{
664671
"condition": "[variables('enablePE')]",
665672
"type": "Microsoft.MachineLearningServices/workspaces",
666-
"apiVersion": "2023-04-01-preview",
673+
"apiVersion": "2023-08-01-preview",
667674
"tags": "[parameters('tagValues')]",
668675
"name": "[parameters('workspaceName')]",
669676
"kind": "[parameters('kind')]",
@@ -680,7 +687,8 @@
680687
"hubResourceId": "[parameters('workspace_hub')]",
681688
"azureOpenAI": {
682689
"resourceId": "[parameters('byo_open_ai_resource_id')]"
683-
}
690+
},
691+
"serverlessComputeSettings": "[parameters('serverless_compute_settings')]"
684692
}
685693
}
686694
]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def __init__(
399399

400400
self._workspaces = WorkspaceOperations(
401401
self._ws_operation_scope if registry_reference else self._operation_scope,
402-
self._service_client_06_2023_preview,
402+
self._service_client_08_2023_preview,
403403
self._operation_container,
404404
self._credential,
405405
**app_insights_handler_kwargs,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# ---------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# ---------------------------------------------------------
4+
from marshmallow import fields
5+
from marshmallow.decorators import post_load
6+
7+
from azure.ai.ml._schema._utils.utils import validate_arm_str
8+
from azure.ai.ml._schema.core.schema import PathAwareSchema
9+
from azure.ai.ml.entities._workspace.serverless_compute import ServerlessComputeSettings
10+
11+
12+
class ServerlessComputeSettingsSchema(PathAwareSchema):
13+
"""Schema for ServerlessComputeSettings.
14+
15+
:param custom_subnet: The custom subnet to use for serverless computes created in the workspace.
16+
:type custom_subnet: str. Formatted as ARM ID.
17+
:param no_public_ip: Whether to disable public ip for the compute. Only valid if custom_subnet is defined.
18+
:type no_public_ip: bool
19+
"""
20+
21+
custom_subnet = fields.Str(validate=validate_arm_str)
22+
no_public_ip = fields.Bool(load_default=False)
23+
24+
@post_load
25+
def make(self, data, **_kwargs) -> ServerlessComputeSettings:
26+
"""Create a ServerlessComputeSettings object from the marshmallow schema.
27+
28+
:param data: The data from which the ServerlessComputeSettings are being loaded.
29+
:type data: OrderedDict[str, Any]
30+
:returns: A ServerlessComputeSettings object.
31+
:rtype: azure.ai.ml.entities._workspace.serverless_compute.ServerlessComputeSettings
32+
"""
33+
custom_subnet = data.pop("custom_subnet")
34+
no_public_ip = data.pop("no_public_ip")
35+
return ServerlessComputeSettings(custom_subnet, no_public_ip)

sdk/ml/azure-ai-ml/azure/ai/ml/_schema/workspace/workspace.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
# Copyright (c) Microsoft Corporation. All rights reserved.
33
# ---------------------------------------------------------
44

5-
from marshmallow import fields, EXCLUDE
5+
from marshmallow import EXCLUDE, fields
66

7+
from azure.ai.ml._schema import ExperimentalField
78
from azure.ai.ml._schema._utils.utils import validate_arm_str
89
from azure.ai.ml._schema.core.fields import NestedField, StringTransformedEnum
910
from azure.ai.ml._schema.core.schema import PathAwareSchema
1011
from azure.ai.ml._schema.workspace.customer_managed_key import CustomerManagedKeySchema
1112
from azure.ai.ml._schema.workspace.identity import IdentitySchema
13+
from azure.ai.ml._schema.workspace.networking import ManagedNetworkSchema
14+
from azure.ai.ml._schema.workspace.serverless_compute import ServerlessComputeSettingsSchema
1215
from azure.ai.ml._utils.utils import snake_to_pascal
1316
from azure.ai.ml.constants._common import PublicNetworkAccess
14-
from azure.ai.ml._schema.workspace.networking import ManagedNetworkSchema
15-
16-
from azure.ai.ml._schema import ExperimentalField
1717

1818

1919
class WorkspaceSchema(PathAwareSchema):
@@ -42,3 +42,4 @@ class WorkspaceSchema(PathAwareSchema):
4242
workspace_hub = fields.Str(validate=validate_arm_str)
4343
managed_network = ExperimentalField(NestedField(ManagedNetworkSchema, unknown=EXCLUDE))
4444
enable_data_isolation = fields.Bool()
45+
serverless_compute = NestedField(ServerlessComputeSettingsSchema)

0 commit comments

Comments
 (0)