Skip to content

Commit 8d51344

Browse files
authored
Compute Instance OS patching and Release quota (#34563)
* new CI args * run black * feedback
1 parent ebe2d01 commit 8d51344

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,9 @@ class ComputeInstanceSchema(ComputeSchema):
7575
enable_root_access = fields.Bool(
7676
metadata={"description": "Enable or disable root access for the compute instance."}
7777
)
78+
release_quota_on_stop = fields.Bool(
79+
metadata={"description": "Release quota on stop for the compute instance. Defaults to False."}
80+
)
81+
enable_os_patching = fields.Bool(
82+
metadata={"description": "Enable or disable OS patching for the compute instance. Defaults to False."}
83+
)

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ class ComputeInstance(Compute):
167167
:type enable_sso: bool
168168
:param enable_root_access: Enable or disable root access. Defaults to True.
169169
:type enable_root_access: bool
170+
:param release_quota_on_stop: Release quota on stop for the compute instance. Defaults to False.
171+
:type release_quota_on_stop: bool
172+
:param enable_os_patching: Enable or disable OS patching for the compute instance. Defaults to False.
173+
:type enable_os_patching: bool
170174
171175
.. admonition:: Example:
172176
@@ -198,6 +202,8 @@ def __init__(
198202
custom_applications: Optional[List[CustomApplications]] = None,
199203
enable_sso: bool = True,
200204
enable_root_access: bool = True,
205+
release_quota_on_stop: bool = False,
206+
enable_os_patching: bool = False,
201207
**kwargs: Any,
202208
) -> None:
203209
kwargs[TYPE] = ComputeType.COMPUTEINSTANCE
@@ -226,6 +232,8 @@ def __init__(
226232
self.enable_node_public_ip = enable_node_public_ip
227233
self.enable_sso = enable_sso
228234
self.enable_root_access = enable_root_access
235+
self.release_quota_on_stop = release_quota_on_stop
236+
self.enable_os_patching = enable_os_patching
229237
self.custom_applications = custom_applications
230238
self.subnet = None
231239

@@ -308,6 +316,8 @@ def _to_rest_object(self) -> ComputeResource:
308316
enable_node_public_ip=self.enable_node_public_ip,
309317
enable_sso=self.enable_sso,
310318
enable_root_access=self.enable_root_access,
319+
release_quota_on_stop=self.release_quota_on_stop,
320+
enable_os_patching=self.enable_os_patching,
311321
)
312322
compute_instance_prop.schedules = self.schedules._to_rest_object() if self.schedules else None
313323
compute_instance_prop.setup_scripts = self.setup_scripts._to_rest_object() if self.setup_scripts else None
@@ -453,6 +463,12 @@ def _load_from_rest(cls, rest_obj: ComputeResource) -> "ComputeInstance":
453463
enable_root_access=prop.properties.enable_root_access
454464
if (prop.properties and prop.properties.enable_root_access is not None)
455465
else True,
466+
release_quota_on_stop=prop.properties.release_quota_on_stop
467+
if (prop.properties and prop.properties.release_quota_on_stop is not None)
468+
else False,
469+
enable_os_patching=prop.properties.enable_os_patching
470+
if (prop.properties and prop.properties.enable_os_patching is not None)
471+
else False,
456472
)
457473
return response
458474

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,16 @@ def test_compute_instance_load_from_rest(self):
144144
assert compute_instance2.tags["test3"] == "0"
145145
assert compute_instance2.enable_sso is False
146146
assert compute_instance2.enable_root_access is False
147+
assert compute_instance2.enable_os_patching is True
148+
assert compute_instance2.release_quota_on_stop is True
147149

148150
compute_instance3: ComputeInstance = load_compute(
149151
source="tests/test_configs/compute/compute-ci-defaults-unit.yaml",
150152
)._to_rest_object()
151153
assert compute_instance3.properties.properties.enable_sso is True
152154
assert compute_instance3.properties.properties.enable_root_access is True
155+
assert compute_instance3.properties.properties.enable_os_patching is False
156+
assert compute_instance3.properties.properties.release_quota_on_stop is False
153157

154158
def test_compute_instance_with_image_metadata(self):
155159
os_image_metadata = ImageMetadata(

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
@@ -5,6 +5,8 @@ description: some_desc_ci
55
size: Standard_DS2_v2
66
enable_sso: false
77
enable_root_access: false
8+
release_quota_on_stop: True
9+
enable_os_patching: True
810

911
network_settings:
1012
vnet_name: myvnet-wus2

0 commit comments

Comments
 (0)