Skip to content

Commit

Permalink
[ML] Restore idle_time_before_shutdown property to Compute Instances (A…
Browse files Browse the repository at this point in the history
…zure#27551)

* Restored idle_time_before_shutdown property
  • Loading branch information
nthandeMS committed Nov 19, 2022
1 parent 9295e4b commit ed52c96
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 55 deletions.
25 changes: 15 additions & 10 deletions sdk/ml/azure-ai-ml/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# Release History

## 1.1.1 (Unreleased)
## 1.1.2 (2022-11-21)

## Features Added
### Features Added
- Restored idle_time_before_shutdown property for Compute Instances.
- Deprecated idle_time_before_shutdown property in favor of idle_time_before_shutdown_minutes.

### Bugs Fixed
- Fixed idle_time_before_shutdown appearing as None for Compute Instances returned by `show` or `list`.
- Fixed idle_time_before_shutdown_minutes preventing creation of Compute Instances when set to None.

## 1.1.1 (2022-11-15)

### Breaking Changes
- Renamed idle_time_before_shutdown to idle_time_before_shutdown_minutes and changed input type to int.

### Bugs Fixed
- Fixed idle_time_before_shutdown_minutes not appearing in GET calls for Compute Instances.

## 1.1.0 (2022-11-07)

### Features Added
Expand All @@ -14,8 +27,6 @@
- The values of JobService.job_service_type are now using the snake case. e.g jupyter_lab, ssh, tensor_board, vs_code.
- Command function now accepts services param of type Dict[str, JobService] instead of dict.

### Breaking Changes

### Bugs Fixed
- MLClient.from_config can now find the default config.json on Compute Instance when running sample notebooks.
- Fixed job inputs not accepting datastores or job inputs.
Expand All @@ -27,7 +38,6 @@
### Other Changes
- Switched compute operations to go through 2022-10-01-preview API version.


## 1.0.0 (2022-10-10)
- GA release
- Dropped support for Python 3.6. The Python versions supported for this release are 3.7-3.10.
Expand All @@ -41,7 +51,6 @@
- Endpoint and Job use unified identity classes.
- Workspace ManagedServiceIdentity has been replaced by IdentityConfiguration.

### Bugs Fixed

### Other Changes
- Switched Compute operations to use Oct preview API version.
Expand Down Expand Up @@ -116,9 +125,6 @@
- Fixed mismatch errors when updating scale_settings for KubernetesOnlineDeployment.
- Removed az CLI command that was printed when deleting OnlineEndpoint

### Other Changes


## 0.1.0b5 (2022-07-15)

### Features Added
Expand All @@ -131,7 +137,6 @@
- Added end_time to job schedule.
- MIR and pipeline job now support registry assets.

### Breaking Changes

### Bugs Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,21 @@ def make(self, data, **kwargs):


class ComputeInstanceSchema(ComputeSchema):
type = StringTransformedEnum(allowed_values=[ComputeType.COMPUTEINSTANCE], required=True)
type = StringTransformedEnum(
allowed_values=[ComputeType.COMPUTEINSTANCE], required=True
)
size = fields.Str()
network_settings = NestedField(NetworkSettingsSchema)
create_on_behalf_of = NestedField(CreateOnBehalfOfSchema)
ssh_settings = NestedField(ComputeInstanceSshSettingsSchema)
ssh_public_access_enabled = fields.Bool(dump_default=None)
state = fields.Str(dump_only=True)
last_operation = fields.Dict(keys=fields.Str(), values=fields.Str(), dump_only=True)
services = fields.List(fields.Dict(keys=fields.Str(), values=fields.Str()), dump_only=True)
services = fields.List(
fields.Dict(keys=fields.Str(), values=fields.Str()), dump_only=True
)
schedules = NestedField(ComputeSchedulesSchema)
identity = ExperimentalField(NestedField(IdentitySchema))
idle_time_before_shutdown = ExperimentalField(fields.Str())
idle_time_before_shutdown_minutes = ExperimentalField(fields.Int())
setup_scripts = ExperimentalField(NestedField(SetupScriptsSchema))
4 changes: 4 additions & 0 deletions sdk/ml/azure-ai-ml/azure/ai/ml/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------

<<<<<<< HEAD
VERSION = "1.1.1"
=======
VERSION = "1.1.2"
>>>>>>> 743c09d283 ([ML] Restore idle_time_before_shutdown property to Compute Instances (#27551))
2 changes: 2 additions & 0 deletions sdk/ml/azure-ai-ml/azure/ai/ml/entities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from ._compute._schedule import ComputePowerAction, ComputeSchedules, ComputeStartStopSchedule, ScheduleState
from ._compute._usage import Usage, UsageName
from ._compute._vm_size import VmSize
from ._compute._image_metadata import ImageMetadata
from ._compute.aml_compute import AmlCompute, AmlComputeSshSettings
from ._compute.compute import Compute, NetworkSettings
from ._compute.compute_instance import AssignedUserConfiguration, ComputeInstance, ComputeInstanceSshSettings
Expand Down Expand Up @@ -216,6 +217,7 @@
"SynapseSparkCompute",
"AutoScaleSettings",
"AutoPauseSettings",
"ImageMetadata",
# builders
"Command",
"Parallel",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
# pylint: disable=protected-access,too-many-instance-attributes

import re
import warnings
import logging
from typing import Dict, List, Optional

from azure.ai.ml._restclient.v2022_10_01_preview.models import AssignedUser
from azure.ai.ml._restclient.v2022_10_01_preview.models import ComputeInstance as CIRest
from azure.ai.ml._restclient.v2022_10_01_preview.models import ComputeInstanceSshSettings as CiSShSettings
from azure.ai.ml._restclient.v2022_10_01_preview.models import (
ComputeInstanceSshSettings as CiSShSettings,
)
from azure.ai.ml._restclient.v2022_10_01_preview.models import (
ComputeResource,
PersonalComputeInstanceSettings,
Expand All @@ -29,6 +33,8 @@
from ._schedule import ComputeSchedules
from ._setup_scripts import SetupScripts

module_logger = logging.getLogger(__name__)


class ComputeInstanceSshSettings:
"""Credentials for an administrator user account to SSH into the compute
Expand Down Expand Up @@ -123,6 +129,10 @@ class ComputeInstance(Compute):
:type schedules: Optional[ComputeSchedules], optional
:param identity: The identity configuration, identities that are associated with the compute cluster.
:type identity: IdentityConfiguration, optional
:param idle_time_before_shutdown: Deprecated. Use :param: `idle_time_before_shutdown_minutes` instead.
Stops compute instance after user defined period of inactivity.
Time is defined in ISO8601 format. Minimum is 15 min, maximum is 3 days.
:type idle_time_before_shutdown: Optional[str], optional
:param idle_time_before_shutdown_minutes: Stops compute instance after a user defined period of
inactivity in minutes. Minimum is 15 min, maximum is 3 days.
:type idle_time_before_shutdown_minutes: Optional[int], optional
Expand All @@ -142,6 +152,7 @@ def __init__(
ssh_settings: Optional[ComputeInstanceSshSettings] = None,
schedules: Optional[ComputeSchedules] = None,
identity: IdentityConfiguration = None,
idle_time_before_shutdown: Optional[str] = None,
idle_time_before_shutdown_minutes: Optional[int] = None,
setup_scripts: Optional[SetupScripts] = None,
**kwargs,
Expand All @@ -164,6 +175,7 @@ def __init__(
self.ssh_settings = ssh_settings
self.schedules = schedules
self.identity = identity
self.idle_time_before_shutdown = idle_time_before_shutdown
self.idle_time_before_shutdown_minutes = idle_time_before_shutdown_minutes
self.setup_scripts = setup_scripts
self.subnet = None
Expand Down Expand Up @@ -230,12 +242,23 @@ def _to_rest_object(self) -> ComputeResource:
)
)

idle_time_before_shutdown = None
if self.idle_time_before_shutdown_minutes:
idle_time_before_shutdown = f"PT{self.idle_time_before_shutdown_minutes}M"
elif self.idle_time_before_shutdown:
warnings.warn(
""" The property 'idle_time_before_shutdown' is deprecated.
Please use'idle_time_before_shutdown_minutes' instead.""",
DeprecationWarning,
)
idle_time_before_shutdown = self.idle_time_before_shutdown

compute_instance_prop = ComputeInstanceProperties(
vm_size=self.size if self.size else ComputeDefaults.VMSIZE,
subnet=subnet_resource,
ssh_settings=ssh_settings,
personal_compute_instance_settings=personal_compute_instance_settings,
idle_time_before_shutdown=f"PT{self.idle_time_before_shutdown_minutes}M",
idle_time_before_shutdown=idle_time_before_shutdown,
)
compute_instance_prop.schedules = (
self.schedules._to_rest_object() if self.schedules else None
Expand Down Expand Up @@ -309,6 +332,7 @@ def _load_from_rest(cls, rest_obj: ComputeResource) -> "ComputeInstance":
else None,
)

idle_time_before_shutdown = None
idle_time_before_shutdown_minutes = None
idle_time_before_shutdown_pattern = r"PT([0-9]+)M"
if prop.properties and prop.properties.idle_time_before_shutdown:
Expand Down Expand Up @@ -363,6 +387,7 @@ def _load_from_rest(cls, rest_obj: ComputeResource) -> "ComputeInstance":
setup_scripts=SetupScripts._from_rest_object(prop.properties.setup_scripts)
if prop.properties and prop.properties.setup_scripts
else None,
idle_time_before_shutdown=idle_time_before_shutdown,
idle_time_before_shutdown_minutes=idle_time_before_shutdown_minutes,
)
return response
Expand Down
Loading

0 comments on commit ed52c96

Please sign in to comment.