Schedule 类

定义要提交管道的计划。

发布管道后,可以使用“计划”按指定的时间间隔或在检测到 Blob 存储位置的更改时提交管道。

初始化计划。

继承
builtins.object
Schedule

构造函数

Schedule(workspace, id, name, description, pipeline_id, status, recurrence, datastore_name, polling_interval, data_path_parameter_name, continue_on_step_failure, path_on_datastore, _schedule_provider=None, pipeline_endpoint_id=None)

参数

workspace
Workspace
必需

此计划所属的工作区对象。

id
str
必需

计划的 ID。

name
str
必需

计划的名称。

description
str
必需

计划的说明。

pipeline_id
str
必需

计划提交的管道的 ID。

status
str
必需

计划的状态,即“活动”或“已禁用”。

recurrence
ScheduleRecurrence
必需

管道的计划重复周期。

datastore_name
str
必需

要在其中监视已修改/已添加的 Blob 的数据存储的名称。 注意:不支持 1) VNET 数据存储。 2) 数据存储的身份验证类型应设置为“帐户密钥”。

polling_interval
int
必需

轮询已修改/已添加的 Blob 的间隔时间(分钟)。

data_path_parameter_name
str
必需

要使用更改的 Blob 路径设置的数据路径管道参数的名称。

continue_on_step_failure
bool
必需

当某个步骤失败时,是否继续执行提交的 PipelineRun 中的其他步骤。 如果提供了此参数,则将重写管道的 continue_on_step_failure 设置。

path_on_datastore
str
必需

可选。 要在其中监视已修改/已添加的 Blob 的数据存储上的路径。 注意:path_on_datastore 将位于数据存储的容器下,因此计划将监视的实际路径将为 container/path_on_datastore。 如果没有此路径,将监视数据存储容器。 不会监视在 path_on_datastore 的子文件夹中进行的添加/修改。 仅支持数据存储计划。

_schedule_provider
<xref:azureml.pipeline.core._aeva_provider._AevaScheduleProvider>
默认值: None

计划提供程序。

workspace
Workspace
必需

此计划所属的工作区对象。

id
str
必需

计划的 ID。

name
str
必需

计划的名称。

description
str
必需

计划的说明。

pipeline_id
str
必需

计划提交的管道的 ID。

status
str
必需

计划的状态,即“活动”或“已禁用”。

recurrence
ScheduleRecurrence
必需

管道的计划重复周期。

datastore_name
str
必需

要在其中监视已修改/已添加的 Blob 的数据存储的名称。 注意:VNET 数据存储不受支持。

polling_interval
int
必需

轮询已修改/已添加的 Blob 的间隔时间(分钟)。

data_path_parameter_name
str
必需

要使用更改的 Blob 路径设置的数据路径管道参数的名称。

continue_on_step_failure
bool
必需

当某个步骤失败时,是否继续执行提交的 PipelineRun 中的其他步骤。 如果提供了此参数,则将重写管道的 continue_on_step_failure 设置。

path_on_datastore
str
必需

可选。 要在其中监视已修改/已添加的 Blob 的数据存储上的路径。 注意:path_on_datastore 将位于数据存储的容器下,因此计划将监视的实际路径将为 container/path_on_datastore。 如果没有此路径,将监视数据存储容器。 不会监视在 path_on_datastore 的子文件夹中进行的添加/修改。 仅支持数据存储计划。

_schedule_provider
<xref:azureml.pipeline.core._aeva_provider._AevaScheduleProvider>
必需

计划提供程序。

pipeline_endpoint_id
str
默认值: None

计划提交的管道终结点的 ID。

注解

支持两种类型的计划。 第一个使用时间重复周期按给定的计划提交管道。 第二个监视 AzureBlobDatastore 用于已添加或修改的 Blob,并提交管道(在检测到更改时)。

若要创建将按重复计划提交管道的计划,请在创建计划时使用 ScheduleRecurrence

为管道创建计划时,将使用 ScheduleRecurrence,如下所示:


   from azureml.pipeline.core import Schedule, ScheduleRecurrence

   recurrence = ScheduleRecurrence(frequency="Hour", interval=12)
   schedule = Schedule.create(workspace, name="TestSchedule", pipeline_id="pipeline_id",
                              experiment_name="helloworld", recurrence=recurrence)

此计划将每 12 小时提交所提供的 PublishedPipeline 一次。 已提交的管道将在名为“helloworld”的试验下创建。

若要创建一个计划,该计划将触发 PipelineRun 对 Blob 存储位置的修改,请在创建计划时指定数据存储和相关数据信息。


   from azureml.pipeline.core import Schedule
   from azureml.core.datastore import Datastore

   datastore = Datastore(workspace=ws, name="workspaceblobstore")

   schedule = Schedule.create(workspace, name="TestSchedule", pipeline_id="pipeline_id"
                              experiment_name="helloworld", datastore=datastore,
                              polling_interval=5, path_on_datastore="file/path")

请注意,polling_interval 和 path_on_datastore 参数是可选的。 Polling_interval 指定轮询对数据存储进行修改的频率,默认情况下为 5 分钟。 path_on_datastore 可用于指定数据存储上用于监视更改的文件夹。 如果没有此路径,将监视数据存储容器。 注意:如果未指定 path_on_datastore,则不会检测到 path_on_datastore 的子文件夹中的 Blob 添加/修改或数据存储容器。

此外,如果管道构造为使用 DataPathPipelineParameter 来描述步骤输入,则在创建数据存储触发的计划时,请使用 data_path_parameter_name 参数,在按计划提交 PipelineRun 时将输入设置为更改的文件。

在以下示例中,当计划触发 PipelineRun 时,“input_data”PipelineParameter 的值将设置为修改/添加的文件:


   from azureml.pipeline.core import Schedule
   from azureml.core.datastore import Datastore

   datastore = Datastore(workspace=ws, name="workspaceblobstore")

   schedule = Schedule.create(workspace, name="TestSchedule", pipeline_id="pipeline_id",
                              experiment_name="helloworld", datastore=datastore,
                              data_path_parameter_name="input_data")

有关计划的更多信息,请参阅 https://aka.ms/pl-schedule

方法

create

为管道创建计划。

为基于时间的计划指定重复周期,或指定数据存储、(可选的)polling_interval 以及(可选的)data_path_parameter_name,以创建一个计划,该计划将监视用于修改/添加数据的数据存储位置。

create_for_pipeline_endpoint

为管道终结点创建计划。

为基于时间的计划指定重复周期,或指定数据存储、(可选的)polling_interval 以及(可选的)data_path_parameter_name,以创建一个计划,该计划将监视用于修改/添加数据的数据存储位置。

disable

将计划设置为“已禁用”且无法运行。

enable

将计划设置为“活动”且可供运行。

get

获取具有给定 ID 的计划。

get_all

获取当前工作区中的所有计划。

已弃用:已弃用此方法,以支持 list 方法。

get_last_pipeline_run

提取计划提交的最后一个管道运行。 如果未提交任何运行,则返回 None。

get_pipeline_runs

提取从计划生成的管道运行。

get_schedules_for_pipeline_endpoint_id

获取给定管道终结点 ID 的所有计划。

get_schedules_for_pipeline_id

获取给定管道 ID 的所有计划。

list

获取当前工作区中的所有计划。

load_yaml

加载并读取 YAML 文件,获取计划参数。

YAML 文件是传递计划参数以创建计划的另外一种方法。

update

更新计划。

create

为管道创建计划。

为基于时间的计划指定重复周期,或指定数据存储、(可选的)polling_interval 以及(可选的)data_path_parameter_name,以创建一个计划,该计划将监视用于修改/添加数据的数据存储位置。

static create(workspace, name, pipeline_id, experiment_name, recurrence=None, description=None, pipeline_parameters=None, wait_for_provisioning=False, wait_timeout=3600, datastore=None, polling_interval=5, data_path_parameter_name=None, continue_on_step_failure=None, path_on_datastore=None, _workflow_provider=None, _service_endpoint=None)

参数

workspace
Workspace
必需

此计划所属的工作区对象。

name
str
必需

计划的名称。

pipeline_id
str
必需

计划提交的管道的 ID。

experiment_name
str
必需

提交计划将在其上运行的试验的名称。

recurrence
ScheduleRecurrence
默认值: None

管道的计划重复周期。

description
str
默认值: None

计划的说明。

pipeline_parameters
dict
默认值: None

用于分配新值的参数的字典 {param name, param value}

wait_for_provisioning
bool
默认值: False

是否等待计划预配完成。

wait_timeout
int
默认值: 3600

超时之前等待的秒数。

datastore
AzureBlobDatastore
默认值: None

要在其中监视已修改/已添加的 Blob 的数据存储。 注意:VNET 数据存储不受支持。 不能与重复项一起使用。

polling_interval
int
默认值: 5

轮询已修改/已添加的 Blob 的间隔时间(分钟)。 默认值为 5 分钟。 仅支持数据存储计划。

data_path_parameter_name
str
默认值: None

要使用更改的 Blob 路径设置的数据路径管道参数的名称。 仅支持数据存储计划。

continue_on_step_failure
bool
默认值: None

当某个步骤失败时,是否继续执行提交的 PipelineRun 中的其他步骤。 如果提供了此参数,则将重写管道的 continue_on_step_failure 设置。

path_on_datastore
str
默认值: None

可选。 要在其中监视已修改/已添加的 Blob 的数据存储上的路径。 注意:path_on_datastore 将位于数据存储的容器下,因此计划将监视的实际路径将为 container/path_on_datastore。 如果没有此路径,将监视数据存储容器。 不会监视在 path_on_datastore 的子文件夹中进行的添加/修改。 仅支持数据存储计划。

_workflow_provider
<xref:azureml.pipeline.core._aeva_provider._AevaWorkflowProvider>
默认值: None

工作流提供程序。

_service_endpoint
str
默认值: None

服务终结点。

返回

创建的计划。

返回类型

create_for_pipeline_endpoint

为管道终结点创建计划。

为基于时间的计划指定重复周期,或指定数据存储、(可选的)polling_interval 以及(可选的)data_path_parameter_name,以创建一个计划,该计划将监视用于修改/添加数据的数据存储位置。

static create_for_pipeline_endpoint(workspace, name, pipeline_endpoint_id, experiment_name, recurrence=None, description=None, pipeline_parameters=None, wait_for_provisioning=False, wait_timeout=3600, datastore=None, polling_interval=5, data_path_parameter_name=None, continue_on_step_failure=None, path_on_datastore=None, _workflow_provider=None, _service_endpoint=None)

参数

workspace
Workspace
必需

此计划将属于的工作区对象。

name
str
必需

计划的名称。

pipeline_endpoint_id
str
必需

计划提交的管道终结点的 ID。

experiment_name
str
必需

提交计划将在其上运行的试验的名称。

recurrence
ScheduleRecurrence
默认值: None

管道的计划重复周期。

description
str
默认值: None

计划的说明。

pipeline_parameters
dict
默认值: None

用于分配新值的参数的字典 {param name, param value}

wait_for_provisioning
bool
默认值: False

是否等待计划预配完成。

wait_timeout
int
默认值: 3600

超时之前等待的秒数。

datastore
AzureBlobDatastore
默认值: None

要在其中监视已修改/已添加的 Blob 的数据存储。 注意:VNET 数据存储不受支持。 不能与重复项一起使用。

polling_interval
int
默认值: 5

轮询已修改/已添加的 Blob 的间隔时间(分钟)。 默认值为 5 分钟。 仅支持数据存储计划。

data_path_parameter_name
str
默认值: None

要使用更改的 Blob 路径设置的数据路径管道参数的名称。 仅支持数据存储计划。

continue_on_step_failure
bool
默认值: None

当某个步骤失败时,是否继续执行提交的 PipelineRun 中的其他步骤。 如果提供了此参数,则将重写管道的 continue_on_step_failure 设置。

path_on_datastore
str
默认值: None

可选。 要在其中监视已修改/已添加的 Blob 的数据存储上的路径。 注意:path_on_datastore 将位于数据存储的容器下,因此计划将监视的实际路径将为 container/path_on_datastore。 如果没有此路径,将监视数据存储容器。 不会监视在 path_on_datastore 的子文件夹中进行的添加/修改。 仅支持数据存储计划。

_workflow_provider
<xref:azureml.pipeline.core._aeva_provider._AevaWorkflowProvider>
默认值: None

工作流提供程序。

_service_endpoint
str
默认值: None

服务终结点。

返回

创建的计划。

返回类型

disable

将计划设置为“已禁用”且无法运行。

disable(wait_for_provisioning=False, wait_timeout=3600)

参数

wait_for_provisioning
bool
默认值: False

是否等待计划预配完成。

wait_timeout
int
默认值: 3600

超时之前等待的秒数。

enable

将计划设置为“活动”且可供运行。

enable(wait_for_provisioning=False, wait_timeout=3600)

参数

wait_for_provisioning
bool
默认值: False

是否等待计划预配完成。

wait_timeout
int
默认值: 3600

超时之前等待的秒数。

get

获取具有给定 ID 的计划。

static get(workspace, id, _workflow_provider=None, _service_endpoint=None)

参数

workspace
Workspace
必需

创建计划的工作区。

id
str
必需

计划的 ID。

_workflow_provider
<xref:azureml.pipeline.core._aeva_provider._AevaWorkflowProvider>
默认值: None

工作流提供程序。

_service_endpoint
str
默认值: None

服务终结点。

返回

Schedule 对象

返回类型

get_all

获取当前工作区中的所有计划。

已弃用:已弃用此方法,以支持 list 方法。

static get_all(workspace, active_only=True, pipeline_id=None, pipeline_endpoint_id=None, _workflow_provider=None, _service_endpoint=None)

参数

workspace
Workspace
必需

工作区。

active_only
bool
默认值: True

如果为 true,则仅返回当前处于活动状态的计划。 仅在未提供管道 ID 时适用。

pipeline_id
str
默认值: None

如果提供,则仅返回具有给定 ID 的管道的计划。

pipeline_endpoint_id
str
默认值: None

如果提供,则仅返回具有给定 ID 的管道终结点的计划。

_workflow_provider
<xref:azureml.pipeline.core._aeva_provider._AevaWorkflowProvider>
默认值: None

工作流提供程序。

_service_endpoint
str
默认值: None

服务终结点。

返回

Schedule 的列表。

返回类型

get_last_pipeline_run

提取计划提交的最后一个管道运行。 如果未提交任何运行,则返回 None。

get_last_pipeline_run()

返回

最后一个管道运行。

返回类型

get_pipeline_runs

提取从计划生成的管道运行。

get_pipeline_runs()

返回

PipelineRun 的列表。

返回类型

get_schedules_for_pipeline_endpoint_id

获取给定管道终结点 ID 的所有计划。

static get_schedules_for_pipeline_endpoint_id(workspace, pipeline_endpoint_id, _workflow_provider=None, _service_endpoint=None)

参数

workspace
Workspace
必需

工作区。

pipeline_endpoint_id
str
必需

管道终结点 ID。

_workflow_provider
<xref:azureml.pipeline.core._aeva_provider._AevaWorkflowProvider>
默认值: None

工作流提供程序。

_service_endpoint
str
默认值: None

服务终结点。

返回

Schedule 的列表。

返回类型

get_schedules_for_pipeline_id

获取给定管道 ID 的所有计划。

static get_schedules_for_pipeline_id(workspace, pipeline_id, _workflow_provider=None, _service_endpoint=None)

参数

workspace
Workspace
必需

工作区。

pipeline_id
str
必需

管道 ID。

_workflow_provider
<xref:azureml.pipeline.core._aeva_provider._AevaWorkflowProvider>
默认值: None

工作流提供程序。

_service_endpoint
str
默认值: None

服务终结点。

返回

Schedule 的列表。

返回类型

list

获取当前工作区中的所有计划。

static list(workspace, active_only=True, pipeline_id=None, pipeline_endpoint_id=None, _workflow_provider=None, _service_endpoint=None)

参数

workspace
Workspace
必需

工作区。

active_only
bool
默认值: True

如果为 true,则仅返回当前处于活动状态的计划。 仅在未提供管道 ID 时适用。

pipeline_id
str
默认值: None

如果提供,则仅返回具有给定 ID 的管道的计划。

pipeline_endpoint_id
str
默认值: None

如果提供,则仅返回具有给定 ID 的管道终结点的计划。

_workflow_provider
<xref:azureml.pipeline.core._aeva_provider._AevaWorkflowProvider>
默认值: None

工作流提供程序。

_service_endpoint
str
默认值: None

服务终结点。

返回

Schedule 的列表。

返回类型

load_yaml

加载并读取 YAML 文件,获取计划参数。

YAML 文件是传递计划参数以创建计划的另外一种方法。

static load_yaml(workspace, filename, _workflow_provider=None, _service_endpoint=None)

参数

workspace
Workspace
必需

工作区。

filename
str
必需

具有位置的 YAML 文件名。

_workflow_provider
<xref:azureml.pipeline.core._aeva_provider._AevaWorkflowProvider>
默认值: None

工作流提供程序。

_service_endpoint
str
默认值: None

服务终结点。

返回

Schedule 参数和值的字典。

返回类型

注解

计划支持两种类型的 YAML。 第一次读取并加载计划创建以触发管道的重复信息。 第二次读取并加载计划创建以触发管道的数据存储信息。

创建计划的示例,它将在重复周期提交管道,如下所示:


   from azureml.pipeline.core import Schedule

   schedule_info = Schedule.load_yaml(workspace=workspace,
                                      filename='./yaml/test_schedule_with_recurrence.yaml')
   schedule = Schedule.create(workspace, name="TestSchedule", pipeline_id="pipeline_id",
                              experiment_name="helloworld", recurrence=schedule_info.get("recurrence"),
                              description=schedule_info.get("description"))

示例 YAML 文件 test_schedule_with_recurrence.yaml:


   Schedule:
       description: "Test create with recurrence"
       recurrence:
           frequency: Week # Can be "Minute", "Hour", "Day", "Week", or "Month".
           interval: 1 # how often fires
           start_time: 2019-06-07T10:50:00
           time_zone: UTC
           hours:
           - 1
           minutes:
           - 0
           time_of_day: null
           week_days:
           - Friday
       pipeline_parameters: {'a':1}
       wait_for_provisioning: True
       wait_timeout: 3600
       datastore_name: ~
       polling_interval: ~
       data_path_parameter_name: ~
       continue_on_step_failure: None
       path_on_datastore: ~

创建计划的示例,它将在数据存储提交管道,如下所示:


   from azureml.pipeline.core import Schedule

   schedule_info = Schedule.load_yaml(workspace=workspace,
                                      filename='./yaml/test_schedule_with_datastore.yaml')
   schedule = Schedule.create(workspace, name="TestSchedule", pipeline_id="pipeline_id",
                              experiment_name="helloworld",datastore=schedule_info.get("datastore_name"),
                              polling_interval=schedule_info.get("polling_interval"),
                              data_path_parameter_name=schedule_info.get("data_path_parameter_name"),
                              continue_on_step_failure=schedule_info.get("continue_on_step_failure"),
                              path_on_datastore=schedule_info.get("path_on_datastore"))

update

更新计划。

update(name=None, description=None, recurrence=None, pipeline_parameters=None, status=None, wait_for_provisioning=False, wait_timeout=3600, datastore=None, polling_interval=None, data_path_parameter_name=None, continue_on_step_failure=None, path_on_datastore=None)

参数

name
str
默认值: None

计划的新名称。

recurrence
ScheduleRecurrence
默认值: None

管道的新计划重复周期。

description
str
默认值: None

计划的新说明。

pipeline_parameters
dict
默认值: None

用于分配新值的参数的字典 {param name, param value}。

status
str
默认值: None

计划的新状态,即“活动”或“已禁用”。

wait_for_provisioning
bool
默认值: False

是否等待计划预配完成。

wait_timeout
int
默认值: 3600

超时之前等待的秒数。

datastore
AzureBlobDatastore
默认值: None

要在其中监视已修改/已添加的 Blob 的数据存储。 注意:VNET 数据存储不受支持。

polling_interval
int
默认值: None

轮询已修改/已添加的 Blob 的间隔时间(分钟)。 默认值为 5 分钟。

data_path_parameter_name
str
默认值: None

要使用更改的 Blob 路径设置的数据路径管道参数的名称。

continue_on_step_failure
bool
默认值: None

当某个步骤失败时,是否继续执行提交的 PipelineRun 中的其他步骤。 如果提供了此参数,则将重写管道的 continue_on_step_failure 设置。

path_on_datastore
str
默认值: None

可选。 要在其中监视已修改/已添加的 Blob 的数据存储上的路径。 注意:path_on_datastore 将位于数据存储的容器下,因此计划将监视的实际路径将为 container/path_on_datastore。 如果没有此路径,将监视数据存储容器。 不会监视在 path_on_datastore 的子文件夹中进行的添加/修改。 仅支持数据存储计划。

属性

continue_on_step_failure

获取 continue_on_step_failure 设置的值。

返回

continue_on_step_failure 设置的值

返回类型

data_path_parameter_name

获取使用更改的 Blob 路径设置的数据路径管道参数的名称。

返回

数据路径参数名称。

返回类型

str

datastore_name

获取用于计划的数据存储的名称。

返回

数据存储名称。

返回类型

str

description

获取计划的说明。

返回

计划的说明。

返回类型

str

id

获取计划的 ID。

返回

ID。

返回类型

str

name

获取计划的名称。

返回

名称。

返回类型

str

path_on_datastore

获取计划所监视的数据存储上的路径。

返回

数据存储的路径。

返回类型

str

pipeline_endpoint_id

获取计划提交的管道终结点的 ID。

返回

ID。

返回类型

str

pipeline_id

获取计划提交的管道的 ID。

返回

ID。

返回类型

str

polling_interval

获取轮询已修改/已添加的 Blob 的间隔时间(分钟)。

返回

轮询间隔。

返回类型

int

recurrence

获取计划重复周期。

返回

计划重复周期。

返回类型

status

获取计划的状态。

返回

计划的状态。

返回类型

str