PipelineRun 类

表示 Pipeline 的运行。

此类可用于在提交管道运行后管理、检查状态和检索运行详细信息。 使用 get_steps 检索由管道运行创建的 StepRun 对象。 其他用途包括检索与管道运行关联的 Graph 对象、提取管道运行的状态,以及等待运行完成。

初始化管道运行。

继承
PipelineRun

构造函数

PipelineRun(experiment, run_id, _service_endpoint=None, **kwags)

参数

experiment
Experiment
必需

与管道运行关联的试验对象。

run_id
str
必需

管道运行的运行 ID。

_service_endpoint
str
默认值: None

要连接到的终结点。

experiment
Experiment
必需

与管道运行关联的试验对象。

run_id
str
必需

管道运行的运行 ID。

_service_endpoint
str
必需

要连接到的终结点。

注解

通过 submit 提交 Pipeline 时,将返回 PipelineRun 对象。 Experiment 的方法。 有关如何创建和提交管道的详细信息,请参阅:https://aka.ms/pl-first-pipeline

还可以使用运行提交到的 Experiment 和 PipelineRun ID 来实例化 PipelineRun,如下所示:


   from azureml.core import Experiment
   from azureml.pipeline.core import PipelineRun

   experiment = Experiment(workspace, "<experiment_name>")
   pipeline_run = PipelineRun(experiment, "<pipeline_run_id>")

使用 PipelineRun 时,请使用:

  • wait_for_completion,用于监视运行状态,并选择性地流式传输运行日志。

  • get_status,用于提取运行状态。

  • cancel,用于取消正在进行的 PipelineRun。

  • get_steps,用于列出生成的 StepRun。 PipelineRun 为管道中的每个步骤生成 StepRun

方法

cancel

取消正在进行的运行。

child_run

为管道运行创建子运行。 不会为 PipelineRun 实现此方法。

complete

将管道运行标记为完成。 不会为 PipelineRun 实现此方法。

管道不支持此方法;完成/失败状态由 Azure ML 后端管理。

fail

将管道运行标记为失败。 不会为 PipelineRun 实现此方法。

管道不支持此方法;完成/失败状态由 Azure ML 后端管理。

find_step_run

按名称在管道中查找步骤运行。

get

根据运行 ID 提取管道运行。

get_graph

获取管道运行的图。

get_pipeline_output

获取给定管道输出的 PortDataReference。

get_pipeline_runs

提取从已发布管道生成的管道运行。

get_status

从服务中提取管道运行的最新状态。

返回的常见值包括“Running”、“Finished”和“Failed”。

get_steps

获取已完成或已开始运行的所有管道步骤的步骤运行。

get_tags

获取运行的标记集。

publish_pipeline

发布管道并使其可重新运行。

可以从此函数返回的 PublishedPipeline 对象获取管道终结点。 通过管道终结点,可以使用 REST 调用从外部应用程序调用管道。 有关如何在调用 REST 终结点时进行身份验证的信息,请参阅 https://aka.ms/pl-restep-auth

与管道运行关联的原始管道将用作已发布管道的基础。

save

将管道 YAML 保存到文件。

wait_for_completion

等待此管道运行完成。

返回等待后的状态。

cancel

取消正在进行的运行。

cancel()

child_run

为管道运行创建子运行。 不会为 PipelineRun 实现此方法。

child_run(name=None, run_id=None, outputs=None)

参数

name
str
默认值: None

子项的可选名称。

run_id
str
默认值: None

子项的运行 ID(可选),否则使用默认值。

outputs
str
默认值: None

用于跟踪子级的可选输出目录。

返回

子运行。

返回类型

Run

例外

complete

将管道运行标记为完成。 不会为 PipelineRun 实现此方法。

管道不支持此方法;完成/失败状态由 Azure ML 后端管理。

complete()

例外

fail

将管道运行标记为失败。 不会为 PipelineRun 实现此方法。

管道不支持此方法;完成/失败状态由 Azure ML 后端管理。

fail()

例外

find_step_run

按名称在管道中查找步骤运行。

find_step_run(name)

参数

name
str
必需

要查找的步骤的名称。

返回

具有所提供名称的 StepRun 对象的列表。

返回类型

get

根据运行 ID 提取管道运行。

static get(workspace, run_id, _service_endpoint=None)

参数

workspace
Workspace
必需

与管道关联的工作区。

run_id
str
必需

管道运行的 ID。

_service_endpoint
str
默认值: None

要连接到的终结点。

返回

PipelineRun 对象。

返回类型

get_graph

获取管道运行的图。

get_graph()

返回

图形。

返回类型

get_pipeline_output

获取给定管道输出的 PortDataReference。

get_pipeline_output(pipeline_output_name)

参数

pipeline_output_name
str
必需

要获取的管道输出的名称。

返回

表示管道输出数据的 PortDataReference。

返回类型

get_pipeline_runs

提取从已发布管道生成的管道运行。

static get_pipeline_runs(workspace, pipeline_id, _service_endpoint=None)

参数

workspace
Workspace
必需

与管道关联的工作区。

pipeline_id
str
必需

已发布管道的 ID。

_service_endpoint
str
默认值: None

要连接到的终结点。

返回

PipelineRun 对象的列表。

返回类型

get_status

从服务中提取管道运行的最新状态。

返回的常见值包括“Running”、“Finished”和“Failed”。

get_status()

返回

字符串形式的最新状态。

返回类型

str

注解

  • NotStarted - 这是客户端运行对象在云提交之前所处的临时状态

  • 正在运行 - 作业已开始在计算目标中运行。

  • 失败 - 运行失败。 通常,运行上的 Error 属性会提供有关原因的详细信息。

  • Finished - 运行已成功完成。

  • Canceled - 在取消请求后,运行现在已成功取消。


   run = experiment.submit(config)
   while run.get_status() not in ['Finished', 'Failed']: # For example purposes only, not exhaustive
       print('Run {} not in terminal state'.format(run.id))
       time.sleep(10)

get_steps

获取已完成或已开始运行的所有管道步骤的步骤运行。

get_steps()

返回

StepRun 对象的列表。

返回类型

get_tags

获取运行的标记集。

get_tags()

返回

运行的标记字典。

返回类型

publish_pipeline

发布管道并使其可重新运行。

可以从此函数返回的 PublishedPipeline 对象获取管道终结点。 通过管道终结点,可以使用 REST 调用从外部应用程序调用管道。 有关如何在调用 REST 终结点时进行身份验证的信息,请参阅 https://aka.ms/pl-restep-auth

与管道运行关联的原始管道将用作已发布管道的基础。

publish_pipeline(name, description, version, continue_on_step_failure=None, **kwargs)

参数

name
str
必需

已发布管道的名称。

description
str
必需

已发布管道的说明。

version
str
必需

所发布管道的版本。

continue_on_step_failure
bool
默认值: None

当某个步骤失败时,是否继续执行 PipelineRun 中的其他步骤。 默认值为 False。

kwargs
dict
必需

自定义关键字参数,保留供将来开发

返回

已创建发布的管道。

返回类型

save

将管道 YAML 保存到文件。

save(path=None)

参数

path
str
默认值: None

要将 YAML 保存到的路径。 如果该路径为目录,则管道 YAML 文件将保存到 <path>/pipeline.yml。 如果该路径为 None,则使用当前目录。

返回类型

wait_for_completion

等待此管道运行完成。

返回等待后的状态。

wait_for_completion(show_output=True, timeout_seconds=9223372036854775807, raise_on_error=True)

参数

show_output
bool
默认值: True

指示是否在 sys.stdout 中显示管道运行状态。

timeout_seconds
int
默认值: 9223372036854775807

超时之前等待的秒数。

raise_on_error
bool
默认值: True

指示当运行处于失败状态时是否引发错误。

返回

最终状态。

返回类型

str