Skip to content

Commit 5871391

Browse files
authored
Compute instance new params (#33605)
1 parent 558547c commit 5871391

File tree

7 files changed

+42
-7
lines changed

7 files changed

+42
-7
lines changed

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
@@ -452,7 +452,7 @@ def __init__(
452452
self._compute = ComputeOperations(
453453
self._operation_scope,
454454
self._operation_config,
455-
self._service_client_10_2022_preview,
455+
self._service_client_08_2023_preview,
456456
**app_insights_handler_kwargs,
457457
)
458458
self._operation_container.add(AzureMLResourceType.COMPUTE, self._compute)

sdk/ml/azure-ai-ml/azure/ai/ml/_schema/compute/compute_instance.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,7 @@ class ComputeInstanceSchema(ComputeSchema):
7171
enable_node_public_ip = fields.Bool(
7272
metadata={"description": "Enable or disable node public IP address provisioning."}
7373
)
74+
enable_sso = fields.Bool(metadata={"description": "Enable or disable single sign-on for the compute instance."})
75+
enable_root_access = fields.Bool(
76+
metadata={"description": "Enable or disable root access for the compute instance."}
77+
)

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_compute/compute_instance.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
from typing import Dict, List, Optional
1111

1212
from azure.ai.ml._restclient.v2022_10_01_preview.models import AssignedUser
13-
from azure.ai.ml._restclient.v2022_10_01_preview.models import ComputeInstance as CIRest
14-
from azure.ai.ml._restclient.v2022_10_01_preview.models import ComputeInstanceProperties
15-
from azure.ai.ml._restclient.v2022_10_01_preview.models import ComputeInstanceSshSettings as CiSShSettings
16-
from azure.ai.ml._restclient.v2022_10_01_preview.models import (
13+
from azure.ai.ml._restclient.v2023_08_01_preview.models import ComputeInstance as CIRest
14+
from azure.ai.ml._restclient.v2023_08_01_preview.models import ComputeInstanceProperties
15+
from azure.ai.ml._restclient.v2023_08_01_preview.models import ComputeInstanceSshSettings as CiSShSettings
16+
from azure.ai.ml._restclient.v2023_08_01_preview.models import (
1717
ComputeResource,
1818
PersonalComputeInstanceSettings,
1919
ResourceId,
@@ -160,6 +160,10 @@ class ComputeInstance(Compute):
160160
:type setup_scripts: Optional[~azure.ai.ml.entities.SetupScripts]
161161
:param custom_applications: List of custom applications and their endpoints for the compute instance.
162162
:type custom_applications: Optional[List[~azure.ai.ml.entities.CustomApplications]]
163+
:param enable_sso: Enable or disable single sign-on. Defaults to True.
164+
:type enable_sso: bool
165+
:param enable_root_access: Enable or disable root access. Defaults to True.
166+
:type enable_root_access: bool
163167
164168
.. admonition:: Example:
165169
@@ -189,6 +193,8 @@ def __init__(
189193
setup_scripts: Optional[SetupScripts] = None,
190194
enable_node_public_ip: bool = True,
191195
custom_applications: Optional[List[CustomApplications]] = None,
196+
enable_sso: bool = True,
197+
enable_root_access: bool = True,
192198
**kwargs,
193199
) -> None:
194200
kwargs[TYPE] = ComputeType.COMPUTEINSTANCE
@@ -215,6 +221,8 @@ def __init__(
215221
self.idle_time_before_shutdown_minutes = idle_time_before_shutdown_minutes
216222
self.setup_scripts = setup_scripts
217223
self.enable_node_public_ip = enable_node_public_ip
224+
self.enable_sso = enable_sso
225+
self.enable_root_access = enable_root_access
218226
self.custom_applications = custom_applications
219227
self.subnet = None
220228

@@ -295,6 +303,8 @@ def _to_rest_object(self) -> ComputeResource:
295303
personal_compute_instance_settings=personal_compute_instance_settings,
296304
idle_time_before_shutdown=idle_time_before_shutdown,
297305
enable_node_public_ip=self.enable_node_public_ip,
306+
enable_sso=self.enable_sso,
307+
enable_root_access=self.enable_root_access,
298308
)
299309
compute_instance_prop.schedules = self.schedules._to_rest_object() if self.schedules else None
300310
compute_instance_prop.setup_scripts = self.setup_scripts._to_rest_object() if self.setup_scripts else None
@@ -432,6 +442,12 @@ def _load_from_rest(cls, rest_obj: ComputeResource) -> "ComputeInstance":
432442
if (prop.properties and prop.properties.enable_node_public_ip is not None)
433443
else True,
434444
custom_applications=custom_applications,
445+
enable_sso=prop.properties.enable_sso
446+
if (prop.properties and prop.properties.enable_sso is not None)
447+
else True,
448+
enable_root_access=prop.properties.enable_root_access
449+
if (prop.properties and prop.properties.enable_root_access is not None)
450+
else True,
435451
)
436452
return response
437453

sdk/ml/azure-ai-ml/azure/ai/ml/operations/_compute_operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from typing import Any, Dict, Iterable, Optional
88

9-
from azure.ai.ml._restclient.v2023_02_01_preview import AzureMachineLearningWorkspaces as ServiceClient022023Preview
9+
from azure.ai.ml._restclient.v2023_08_01_preview import AzureMachineLearningWorkspaces as ServiceClient022023Preview
1010
from azure.ai.ml._scope_dependent_operations import OperationConfig, OperationScope, _ScopeDependentOperations
1111
from azure.ai.ml._telemetry import ActivityType, monitor_with_activity
1212
from azure.ai.ml._utils._logger_utils import OpsLogger

sdk/ml/azure-ai-ml/tests/compute/unittests/test_compute_entity.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from test_utilities.utils import verify_entity_load_and_dump
99

1010
from azure.ai.ml import load_compute
11-
from azure.ai.ml._restclient.v2022_10_01_preview.models import ComputeResource, ImageMetadata
11+
from azure.ai.ml._restclient.v2023_08_01_preview.models import ComputeResource, ImageMetadata
1212
from azure.ai.ml.constants._compute import CustomApplicationDefaults
1313
from azure.ai.ml.entities import (
1414
AmlCompute,
@@ -142,6 +142,14 @@ def test_compute_instance_load_from_rest(self):
142142
assert compute_instance2.tags["test1"] == "test"
143143
assert compute_instance2.tags["test2"] == "true"
144144
assert compute_instance2.tags["test3"] == "0"
145+
assert compute_instance2.enable_sso is False
146+
assert compute_instance2.enable_root_access is False
147+
148+
compute_instance3: ComputeInstance = load_compute(
149+
source="tests/test_configs/compute/compute-ci-defaults-unit.yaml",
150+
)._to_rest_object()
151+
assert compute_instance3.properties.properties.enable_sso is True
152+
assert compute_instance3.properties.properties.enable_root_access is True
145153

146154
def test_compute_instance_with_image_metadata(self):
147155
os_image_metadata = ImageMetadata(
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: banchci
2+
type: computeinstance
3+
description: some_desc_ci
4+
5+
size: Standard_DS2_v2

sdk/ml/azure-ai-ml/tests/test_configs/compute/compute-ci-unit.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ type: computeinstance
33
description: some_desc_ci
44

55
size: Standard_DS2_v2
6+
enable_sso: false
7+
enable_root_access: false
68

79
network_settings:
810
vnet_name: myvnet-wus2

0 commit comments

Comments
 (0)