共用方式為


CronTrigger 類別

工作排程的 Cron 觸發程式。

繼承
azure.ai.ml.entities._schedule.trigger.TriggerBase
CronTrigger

建構函式

CronTrigger(*, expression: str, start_time: str | datetime | None = None, end_time: str | datetime | None = None, time_zone: str | TimeZone = TimeZone.UTC)

僅限關鍵字的參數

名稱 Description
expression
str

排程的 cron 運算式,遵循 NCronTab 格式。

start_time

觸發程式的開始時間。 如果使用 datetime 物件,請將 tzinfo 保留為 None,並視需要使用 time_zone 參數來指定時區。 如果使用字串,請使用 YYYY-MM-DDThh:mm:ss 格式。 預設會立即執行第一個工作負載,並根據排程繼續未來的工作負載。 如果開始時間是過去的時間,則會在所計算的下一個執行時間執行第一個工作負載。

end_time

觸發程式的開始時間。 如果使用 datetime 物件,請將 tzinfo 保留為 None,並視需要使用 time_zone 參數來指定時區。 如果使用字串,請使用 YYYY-MM-DDThh:mm:ss 格式。 請注意,計算排程不支援end_time。

time_zone

排程執行所在的時區。 預設為 UTC (+00:00) 。 請注意,這適用于start_time和end_time。

預設值: TimeZone.UTC

範例

設定 CronTrigger。


   from datetime import datetime

   from azure.ai.ml.constants import TimeZone
   from azure.ai.ml.entities import CronTrigger

   trigger = CronTrigger(
       expression="15 10 * * 1",
       start_time=datetime(year=2022, month=3, day=10, hour=10, minute=15),
       end_time=datetime(year=2022, month=6, day=10, hour=10, minute=15),
       time_zone=TimeZone.PACIFIC_STANDARD_TIME,
   )