ModuleStep 类

创建 Azure 机器学习管道步骤以运行特定版本的模块。

Module 对象定义可重用的计算(例如脚本或可执行文件),这些计算可以在不同的机器学习方案中由不同的用户使用。 若要在管道中使用特定版本的模块,请创建 ModuleStep。 ModuleStep 是管道中使用现有 ModuleVersion 的步骤。

有关使用 ModuleStep 的示例,请参阅笔记本 https://aka.ms/pl-modulestep

创建 Azure ML 管道步骤以运行特定版本的模块。

继承
ModuleStep

构造函数

ModuleStep(module=None, version=None, module_version=None, inputs_map=None, outputs_map=None, compute_target=None, runconfig=None, runconfig_pipeline_params=None, arguments=None, params=None, name=None, _workflow_provider=None)

参数

名称 说明
module

在步骤中使用的模块。 提供 modulemodule_version 参数,但不能同时提供这两个参数。

默认值: None
version
str

在步骤中使用的模块的版本。

默认值: None
module_version

在步骤中使用的模块的 ModuleVersion。 提供 modulemodule_version 参数,但不能同时提供这两个参数。

默认值: None
inputs_map

一个字典,用于将 ModuleVersion 的端口定义名称映射到步骤的输入。

默认值: None
outputs_map

一个字典,用于将 ModuleVersion 的端口定义名称映射到步骤的输出。

默认值: None
compute_target

要使用的计算目标。 如果未指定,将使用 runconfig 中的目标。 可以是计算目标对象,或工作区上计算目标的字符串名称。 (可选)如果计算目标在管道创建时不可用,可能需要指定一个元组 ('compute target name', 'compute target type') 以避免提取计算目标对象(AmlCompute 类型为“AmlCompute”,RemoteCompute 类型为“VirtualMachine”)。

默认值: None
runconfig

要使用的可选的 RunConfiguration。 RunConfiguration 可用于指定其他运行要求,例如 conda 依赖项和 Docker 映像。

默认值: None
runconfig_pipeline_params

在运行时使用键值对重写 runconfig 属性,每个键值对分别具有 runconfig 属性的名称和该属性的 PipelineParameter。

支持的值:“NodeCount”、“MpiProcessCountPerNode”、“TensorflowWorkerCount”、“TensorflowParameterServerCount”

默认值: None
arguments

Python 脚本文件的命令行参数列表。 这些参数将通过 RunConfiguration 中的参数传递到计算目标。 有关如何处理特殊符号等参数的更多详细信息,请参阅 RunConfiguration 中的参数

默认值: None
params

名称/值对的字典。

默认值: None
name
str

步骤的名称。

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

(仅限内部使用。) 工作流提供程序。

默认值: None
module
必需

在步骤中使用的模块。 提供 modulemodule_version 参数,但不能同时提供这两个参数。

version
必需
str

在步骤中使用的模块的版本。

module_version
必需

步骤中使用的模块的 ModuleVersion。 提供 modulemodule_version 参数,但不能同时提供这两个参数。

inputs_map
必需
dict[str, Union[InputPortBinding, DataReference, PortDataReference, PipelineData, <xref:azureml.pipeline.core.pipeline_output_dataset.PipelineOutputDataset>, DatasetConsumptionConfig]]

一个字典,用于将 ModuleVersion 的端口定义名称映射到步骤的输入。

outputs_map
必需
dict[str, Union[InputPortBinding, DataReference, PortDataReference, PipelineData, <xref:azureml.pipeline.core.pipeline_output_dataset.PipelineOutputDataset>]]

一个字典,用于将 ModuleVersion 的端口定义名称映射到步骤的输出。

compute_target
必需

要使用的计算目标。 如果未指定,将使用 runconfig 中的目标。 可以是计算目标对象,或工作区上计算目标的字符串名称。 (可选)如果计算目标在管道创建时不可用,可能需要指定一个元组 ('compute target name', 'compute target type') 以避免提取计算目标对象(AmlCompute 类型为“AmlCompute”,RemoteCompute 类型为“VirtualMachine”)。

runconfig
必需

要使用的可选的 RunConfiguration。 RunConfiguration 可用于指定其他运行要求,例如 conda 依赖项和 Docker 映像。

runconfig_pipeline_params
必需

在运行时使用键值对重写 runconfig 属性,每个键值对分别具有 runconfig 属性的名称和该属性的 PipelineParameter。

支持的值:“NodeCount”、“MpiProcessCountPerNode”、“TensorflowWorkerCount”、“TensorflowParameterServerCount”

arguments
必需

Python 脚本文件的命令行参数列表。 这些参数将通过 RunConfiguration 中的参数传递到计算目标。 有关如何处理特殊符号等参数的更多详细信息,请参阅 RunConfiguration 中的参数

params
必需

名称/值对的字典。

name
必需
str

步骤的名称。

_wokflow_provider
必需

(仅限内部使用。) 工作流提供程序。

注解

Module 用于创建和管理 Azure 机器学习管道的可重用计算单元。 ModuleStep 是 Azure 机器学习中用于使用模块的内置步骤。 可以专门定义要使用的 ModuleVersion,也可以按照 Module 类的备注部分中定义的解析过程来让 Azure 机器学习解析要使用的 ModuleVersion。 若要定义在提交的管道中使用的 ModuleVersion,请在创建 ModuleStep 时定义以下项之一:

  • ModuleVersion 对象。

  • Module 对象和版本值。

  • 没有版本值的 Module 对象。 在这种情况下,版本解析可能因提交的内容而异。

必须定义 ModuleStep 的输入和输出到 ModuleVersion 的输入和输出的映射。

以下示例演示如何创建 ModuleStep 以将其作为具有多个 ModuleStep 对象的管道的一部分:


   middle_step = ModuleStep(module=module,
                            inputs_map= middle_step_input_wiring,
                            outputs_map= middle_step_output_wiring,
                            runconfig=RunConfiguration(), compute_target=aml_compute,
                            arguments = ["--file_num1", first_sum, "--file_num2", first_prod,
                                         "--output_sum", middle_sum, "--output_product", middle_prod])

完整示例可从 https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-how-to-use-modulestep.ipynb 获取

方法

create_node

从 ModuleStep 步骤创建一个节点并将其添加到指定的图。

此方法不能直接使用。 通过此步骤实例化管道时,Azure ML 会自动通过此方法传递所需的参数,以便可以将步骤添加到表示工作流的管道图形中。

create_node

从 ModuleStep 步骤创建一个节点并将其添加到指定的图。

此方法不能直接使用。 通过此步骤实例化管道时,Azure ML 会自动通过此方法传递所需的参数,以便可以将步骤添加到表示工作流的管道图形中。

create_node(graph, default_datastore, context)

参数

名称 说明
graph
必需

要添加节点的图形对象。

default_datastore
必需

默认数据存储。

context
必需
<xref:azureml.pipeline.core._GraphContext>

图形上下文。

返回

类型 说明

节点对象。