Skip to content

Commit 19f7ef4

Browse files
Merge pull request #233578 from jesscioffi/main
Update how-to-create-manage-compute-instance.md
2 parents 47275d6 + aaa6a01 commit 19f7ef4

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

articles/machine-learning/how-to-create-manage-compute-instance.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -350,29 +350,27 @@ Where the file *create-instance.yml* is:
350350
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
351351

352352
```python
353+
from azure.ai.ml.entities import ComputeInstance, ComputeSchedules, ComputeStartStopSchedule, RecurrenceTrigger, RecurrencePattern
353354
from azure.ai.ml import MLClient
354355
from azure.ai.ml.constants import TimeZone
355-
from azure.ai.ml.entities import ComputeInstance, AmlCompute, ComputeSchedules, ComputeStartStopSchedule, RecurrencePattern, RecurrenceTrigger
356356
from azure.identity import DefaultAzureCredential
357-
from dateutil import tz
358-
import datetime
359-
# Enter details of your Azure Machine Learning workspace
360-
subscription_id = "<guid>"
361-
resource_group = "sample-rg"
362-
workspace = "sample-ws"
357+
358+
subscription_id = "sub-id"
359+
resource_group = "rg-name"
360+
workspace = "ws-name"
363361
# get a handle to the workspace
364362
ml_client = MLClient(
365363
DefaultAzureCredential(), subscription_id, resource_group, workspace
366364
)
367-
ci_minimal_name = "sampleCI"
368-
mytz = tz.gettz("Asia/Kolkata")
369-
now = datetime.datetime.now(tz = mytz)
370-
starttime = now + datetime.timedelta(minutes=25)
371-
triggers = RecurrenceTrigger(frequency="day", interval=1, schedule=RecurrencePattern(hours=17, minutes=30))
372-
myschedule = ComputeStartStopSchedule(start_time=starttime, time_zone=TimeZone.INDIA_STANDARD_TIME, trigger=triggers, action="Stop")
365+
366+
ci_minimal_name = "ci-name"
367+
368+
rec_trigger = RecurrenceTrigger(start_time="yyyy-mm-ddThh:mm:ss", time_zone=TimeZone.INDIA_STANDARD_TIME, frequency="week", interval=1, schedule=RecurrencePattern(week_days=["Friday"], hours=15, minutes=[30]))
369+
myschedule = ComputeStartStopSchedule(trigger=rec_trigger, action="start")
373370
com_sch = ComputeSchedules(compute_start_stop=[myschedule])
374-
ci_minimal = ComputeInstance(name=ci_minimal_name, schedules=com_sch)
375-
ml_client.begin_create_or_update(ci_minimal)
371+
372+
my_compute = ComputeInstance(name=ci_minimal_name, schedules=com_sch)
373+
ml_client.compute.begin_create_or_update(my_compute)
376374
```
377375

378376
### Create a schedule with a Resource Manager template

0 commit comments

Comments
 (0)