You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AzureML Pipeline端点无法按指定start_time触发调度的问题

解决Azure ML调度设置start_time后管道不触发的问题

问题核心原因

设置ScheduleRecurrence的start_time后管道未触发,主要是以下两点问题:

  • AML调度系统默认使用UTC时间,若你的start_time是本地时区时间,转换为UTC后可能早于当前时间,导致调度不会触发;
  • 使用Month频率时未明确指定day参数,调度逻辑模糊,无法精准匹配运行日期。

解决方案

1. 将目标时间转换为UTC

把期望的本地时间转换为UTC后再赋值给start_time,确保时间匹配调度系统的时区规则:

import datetime
import pytz

# 假设目标本地时间是东八区的2022年10月2日16:00
local_time = datetime.datetime(2022, 10, 2, 16, 00, tzinfo=pytz.timezone('Asia/Shanghai'))
# 转换为UTC时间
utc_start_time = local_time.astimezone(pytz.utc)

2. 明确Month频率的运行日期

使用Month频率时,添加day参数指定每月运行的具体日期,消除调度逻辑歧义:

recurrence = ScheduleRecurrence(
    frequency="Month",
    interval=1,
    start_time=utc_start_time,
    day=2  # 指定每月第2天运行
)

3. 确认调度处于激活状态

创建调度后检查状态,若为Disabled则手动启用:

print(f"调度状态: {recurring_schedule.status}")
if recurring_schedule.status == "Disabled":
    recurring_schedule.enable()

4. 确保start_time为未来时间

如果创建调度时start_time已经是过去的时间,调度不会回溯执行,只会从下一个周期触发。例如当前时间是2022年10月3日,设置start_time为2022年10月2日,首次运行会自动延后到2022年11月2日。

完整修正后的调度代码

from azureml.pipeline.core.schedule import ScheduleRecurrence, Schedule
import datetime
import pytz

# 转换目标时间为UTC时区
local_first_run = datetime.datetime(2022, 10, 2, 16, 00, tzinfo=pytz.timezone('Asia/Shanghai'))
utc_first_run = local_first_run.astimezone(pytz.utc)

schedule_name = f"Recocpc monthly run PP {utc_first_run.day:02} {utc_first_run.hour:02}:{utc_first_run.minute:02}"

recurrence = ScheduleRecurrence(
    frequency="Month",
    interval=1,
    start_time=utc_first_run,
    day=2  # 明确每月运行日期
)

recurrence.validate()

recurring_schedule = Schedule.create_for_pipeline_endpoint(
    ws,
    name=schedule_name,
    description="Recocpc monthly run PP",
    pipeline_endpoint_id=pipeline_endpoint.id,
    experiment_name=experiment_name,
    recurrence=recurrence,
    pipeline_parameters={"KEY": "value"}
)

# 检查并激活调度
print(f"调度状态: {recurring_schedule.status}")
if recurring_schedule.status != "Active":
    recurring_schedule.enable()

内容的提问来源于stack exchange,提问作者BeGreen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 01:10:33