PortDataReference 类

为与已完成的 StepRun 的输出关联的数据进行建模。

PortDataReference 对象可用于下载由 StepRun 生成的输出数据。 它还可以用作未来管道中的步骤输入。

初始化 PortDataReference。

继承
builtins.object
PortDataReference

构造函数

PortDataReference(context, pipeline_run_id, data_reference, step_run=None)

参数

名称 说明
context
必需
<xref:azureml.pipeline.core._GraphContext>

图形上下文对象。

pipeline_run_id
必需
str

生成输出的管道运行的 ID。

data_reference
必需

数据引用对象。

step_run

生成数据的 StepRun 对象。

默认值: None
context
必需
<xref:azureml.pipeline.core._GraphContext>

图形上下文对象。

pipeline_run_id
必需
str

生成输出的管道运行的 ID。

data_reference
必需

数据引用对象。

step_run
必需

生成数据的 StepRun 对象。

注解

PortDataReference 指向由已完成的 StepRun 生成的数据。

PipelineRun 获取 PortDataReference 并下载输出数据,如下所示:


   from azureml.pipeline.core import PipelineRun, StepRun, PortDataReference

   pipeline_run = PipelineRun(experiment, "<pipeline_run_id>")
   step_run = pipeline_run.find_step_run("<node_name>")[0]
   port_data_reference = step_run.get_output_data("<output_name>")
   port_data_reference.download(local_path="path")

PortDataReference 可以用作 Pipeline 中的步骤的输入,类似于使用 DataReference

使用 PortDataReference 作为步骤输入的示例如下所示:


   from azureml.pipeline.core import PortDataReference, Pipeline, PipelineRun
   from azureml.pipeline.steps import PythonScriptStep

   pipeline_run = PipelineRun(experiment, "<pipeline_run_id>")
   step_run = pipeline_run.find_step_run("<node_name>")[0]
   port_data_reference = step_run.get_output_data("<output_name>")

   step_1 = PythonScriptStep(
       name='train',
       script_name="train.py",
       compute_target=compute,
       arguments=["--input", port_data_reference],
       inputs=[port_data_reference]
   )

   pipeline = Pipeline(workspace=workspace, steps=[step_1])

在此示例中,新构造的管道将使用已完成的 PipelineRun 创建的输出作为训练步骤的输入。

方法

as_download

通过“下载”模式将 PortDataReference 用作步骤输入。

as_input

创建 InputPortBinding 并指定输入名称(但使用默认模式)。

as_mount

通过“装载”模式将 PortDataReference 用作步骤输入。

create_input_binding

创建以此 PortDataReference 作为源的输入绑定。

download

下载 PortDataReference 表示的数据。

as_download

通过“下载”模式将 PortDataReference 用作步骤输入。

as_download(input_name=None, path_on_compute=None, overwrite=None)

参数

名称 说明
input_name
str

指定此输入的名称。

默认值: None
path_on_compute
str

要将数据下载到的计算的路径。

默认值: None
overwrite

用于指示是否覆盖现有数据。

默认值: None

返回

类型 说明

以此 PortDataReference 作为源的 InputPortBinding。

as_input

创建 InputPortBinding 并指定输入名称(但使用默认模式)。

as_input(input_name)

参数

名称 说明
input_name
必需
str

用于指定此输入的名称。

返回

类型 说明

以此 PortDataReference 作为源的 InputPortBinding。

as_mount

通过“装载”模式将 PortDataReference 用作步骤输入。

as_mount(input_name=None)

参数

名称 说明
input_name
str

用于指定此输入的名称。

默认值: None

返回

类型 说明

以此 PortDataReference 作为源的 InputPortBinding。

create_input_binding

创建以此 PortDataReference 作为源的输入绑定。

create_input_binding(input_name=None, mode=None, path_on_compute=None, overwrite=None)

参数

名称 说明
input_name
str

输入的名称。

默认值: None
mode
str

访问 PortDataReference 的模式(“装载”或“下载”)。

默认值: None
path_on_compute
str

对于“下载”模式,数据将驻留的计算的路径。

默认值: None
overwrite

对于“下载”模式,是否覆盖现有数据。

默认值: None

返回

类型 说明

以此 PortDataReference 作为源的 InputPortBinding。

download

下载 PortDataReference 表示的数据。

download(local_path, overwrite=None, show_progress=None)

参数

名称 说明
local_path
必需
str

要下载到的路径。

overwrite

如果为 true,则覆盖现有文件,默认为 False。

默认值: None
show_progress

在控制台中显示下载进度,默认为 True。

默认值: None

返回

类型 说明
int

成功下载的文件数。

属性

datastore

获取与 PortDataReference 关联的数据存储。

返回

类型 说明

数据存储对象。

datastore_name

获取与 PortDataReference 关联的数据存储的名称。

返回

类型 说明
str

数据存储名称。

name

获取此数据引用的名称。

返回

类型 说明
str

数据引用名称。

path_on_datastore

获取 PortDataReference 的数据存储的路径。

返回

类型 说明
str

数据存储的路径。