@@ -350,29 +350,27 @@ Where the file *create-instance.yml* is:
350
350
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
351
351
352
352
` ` ` python
353
+ from azure.ai.ml.entities import ComputeInstance, ComputeSchedules, ComputeStartStopSchedule, RecurrenceTrigger, RecurrencePattern
353
354
from azure.ai.ml import MLClient
354
355
from azure.ai.ml.constants import TimeZone
355
- from azure.ai.ml.entities import ComputeInstance, AmlCompute, ComputeSchedules, ComputeStartStopSchedule, RecurrencePattern, RecurrenceTrigger
356
356
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"
363
361
# get a handle to the workspace
364
362
ml_client = MLClient(
365
363
DefaultAzureCredential(), subscription_id, resource_group, workspace
366
364
)
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")
373
370
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)
376
374
` ` `
377
375
378
376
# ## Create a schedule with a Resource Manager template
0 commit comments