AzureBatchStep 类

创建用于将作业提交到 Azure Batch 的 Azure ML 管道步骤。

注意:此步骤不支持上传/下载目录及其内容。

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

继承
azureml.pipeline.core._azurebatch_step_base._AzureBatchStepBase
AzureBatchStep

构造函数

AzureBatchStep(name, create_pool=False, pool_id=None, delete_batch_job_after_finish=True, delete_batch_pool_after_finish=False, is_positive_exit_code_failure=True, vm_image_urn='urn:MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter', run_task_as_admin=False, target_compute_nodes=1, vm_size='standard_d1_v2', source_directory=None, executable=None, arguments=None, inputs=None, outputs=None, allow_reuse=True, compute_target=None, version=None)

参数

name
str
必需

[必需] 步骤的名称。

create_pool
bool
默认值: False

指示在运行作业之前是否创建池。

pool_id
str
默认值: None

[必需] 在其中运行作业的池的 ID。 该 ID 可以是现有池,也可以是将在提交作业时创建的池。

delete_batch_job_after_finish
bool
默认值: True

指示在完成作业后是否从 Batch 帐户中删除该作业。

delete_batch_pool_after_finish
bool
默认值: False

指示在完成作业后是否删除池。

is_positive_exit_code_failure
bool
默认值: True

指示在任务退出并返回正代码时作业是否失败。

vm_image_urn
str
默认值: urn:MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter

如果 create_pool 为 True,并且 VM 使用 VirtualMachineConfiguration。 值格式:urn:publisher:offer:sku。 示例:urn:MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter

run_task_as_admin
bool
默认值: False

指示任务是否应该以管理员权限运行。

target_compute_nodes
int
默认值: 1

如果 create_pool 为 True,则指示多少计算节点将添加到池中。

vm_size
str
默认值: standard_d1_v2

如果 create_pool 为 True,则指示计算节点的虚拟机大小。

source_directory
str
默认值: None

包含模块二进制文件、可执行文件、程序集等的本地文件夹。

executable
str
默认值: None

[必需] 要作为作业的一部分执行的命令/可执行文件的名称。

arguments
str
默认值: None

命令/可执行文件的参数。

inputs
list[Union[<xref:azureml.pipeline.core.graph.InputPortBinding,azureml.data.data_reference.DataReference,azureml.pipeline.core.PortDataReference,azureml.pipeline.core.builder.PipelineData>]]
默认值: None

输入端口绑定的列表。 在作业运行之前,会为每个输入创建一个文件夹。 每个输入的文件都将从存储复制到计算节点上的相应文件夹。 例如,如果输入名称为 input1,并且存储上的相对路径为 some/relative/path/that/can/be/really/long/inputfile.txt,则计算上的文件路径将为:./input1/inputfile.txt。 当输入名称超过 32 个字符时,它将被截断并追加一个唯一后缀,以便可以在计算目标上成功创建文件夹名称。

outputs
list[Union[<xref:azureml.pipeline.core.builder.PipelineData,azureml.pipeline.core.pipeline_output_dataset.PipelineOutputAbstractDataset,azureml.pipeline.core.graph.OutputPortBinding>]]
默认值: None

输出端口绑定的列表。 与输入类似,在作业运行之前,会为每个输出创建一个文件夹。 文件夹名称将与输出名称相同。 假设作业会将输出放入该文件夹中。

allow_reuse
bool
默认值: True

指示当使用相同的设置重新运行时,该步骤是否应重用以前的结果。 默认情况下启用重用。 如果步骤内容(脚本/依赖项)以及输入和参数保持不变,则重用此步骤以前运行的输出。 重用该步骤时,不是将作业提交到计算,而是使前一运行的结果立即可供后续步骤使用。 如果使用 Azure 机器学习数据集作为输入,则重用取决于数据集的定义是否已更改,而不是基础数据是否已更改。

compute_target
BatchCompute, str
默认值: None

[必需] 作业运行所在的 BatchCompute 计算。

version
str
默认值: None

用于表示模块功能更改的可选版本标记。

注解

以下示例演示如何在 Azure 机器学习管道中使用 AzureBatchStep。


   step = AzureBatchStep(
               name="Azure Batch Job",
               pool_id="MyPoolName", # Replace this with the pool name of your choice
               inputs=[testdata],
               outputs=[outputdata],
               executable="azurebatch.cmd",
               arguments=[testdata, outputdata],
               compute_target=batch_compute,
               source_directory=binaries_folder,
   )

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

方法

create_node

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

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

create_node

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

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

create_node(graph, default_datastore, context)

参数

graph
Graph
必需

要将节点添加到的图对象。

default_datastore
Union[<xref:azureml.data.azure_storage_datastore.AbstractAzureStorageDatastore,azureml.data.azure_data_lake_datastore.AzureDataLakeDatastore>]
必需

默认数据存储。

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

图上下文。

返回

创建的节点。

返回类型