Path5.Mod1.d - Run Pipelines - Schedules and Triggers Flashcards
RT CT
Two Trigger classes used for scheduling jobs and their respective parameters
- The
RecurrenceTrigger
:
–frequency
: Time units -minute
,hour
,day
,week
,month
–interval
: integer indicating how often the schedule fires - The
CronTrigger
:
–expression
: this needs to be in Cron Syntax
–start_time
: the time to start the trigger
–time_zone
: “Eastern Standard Time” or similar
Explain Crontab Syntax
Cron syntax uses 5 space-delimited fields, where a wildcard *
specifies all possible values.
expression="* * * * *"
in this order:
Minutes: 0-59
Hours: 0-23 MILITARY TIME
Days: NOT SUPPORTED. this value is ignored for *
MONTHS: NOT SUPPORTED. this value is ignored for *
Days-Of-Week: 0-6, 0=Sunday. Or you can use “Sunday”
JS, n t c_j
Class type to schedule a pipeline job and its respective parameters
The JobSchedule
class
- name
: display name of the scheduled job, used as part of a format
- trigger
: an instance of a Trigger class
- create_job
: an instance of the job to run
JS, n t c_j
- Display name format for JobSchedule scheduled jobs
Display names look like:
<name><datetime the job started>
:
Explain what this code does:
from azure.ai.ml.entities import RecurrenceTrigger, JobSchedule schedule_name = "run_every_minute" // 1. What is this doing? one_min_recurrence_trigger = RecurrenceTrigger( frequency="minute", interval=1, ) // 2. What is this doing? job_schedule = JobSchedule( name=schedule_name, trigger=one_min_recurrence_trigger, create_job=pipeline_job ) // 3. What this code doing? job_schedule = ml_client.schedules.begin_create_or_update( schedule=job_schedule ).result() // 4. What this code doing? ml_client.schedules.begin_disable(name=schedule_name).result() ml_client.schedules.begin_delete(name=schedule_name).result()
- Creates a
RecurrenceTrigger
that kicks off once a minute - Creates
JobSchedule
job with the name"run_every_minute"
, using theRecurrentTrigger
we just created and the pipeline_job we created earlier in the deck - Schedules the job and gets and instance of that job
- Disables then deletes the scheduled job via looking up the
schedule_name
Explain what this code does:
schedule_name = "simple_sdk_create_schedule_cron" schedule_start_time = datetime.utcnow() // 1. What this code doing? cron_trigger = CronTrigger( expression="15 15 * * 1", start_time="2022-07-10T10:00:00", # start time time_zone="Eastern Standard Time", # time zone of expression ) // 2. What this code doing? job_schedule = JobSchedule( name=schedule_name, trigger=cron_trigger, create_job=pipeline_job ) // 3. What this code doing? job_schedule = ml_client.schedules.begin_create_or_update( schedule=job_schedule ).result()
- Creates a
CronTrigger
with an expression indicating to run the job every day Monday at 3:15pm. Keep in mind the expression is in military time: 15 mins, 15th hour of the day - Create a new schedule with the trigger
- Adds the new Schedule to the schedules