ParallelRunStep Class

Creates an Azure Machine Learning Pipeline step to process large amounts of data asynchronously and in parallel.

For an example of using ParallelRunStep, see the notebook https://aka.ms/batch-inference-notebooks.

For troubleshooting guide, see https://aka.ms/prstsg. You can find more references there.

Create an Azure ML Pipeline step to process large amounts of data asynchronously and in parallel.

For an example of using ParallelRunStep, see the notebook link https://aka.ms/batch-inference-notebooks.

Inheritance
azureml.pipeline.core._parallel_run_step_base._ParallelRunStepBase
ParallelRunStep

Constructor

ParallelRunStep(name, parallel_run_config, inputs, output=None, side_inputs=None, arguments=None, allow_reuse=True)

Parameters

Name Description
name
Required
str

Name of the step. Must be unique to the workspace, only consist of lowercase letters, numbers, or dashes, start with a letter, and be between 3 and 32 characters long.

parallel_run_config
Required

A ParallelRunConfig object used to determine required run properties.

inputs
Required

List of input datasets. All datasets in the list should be of same type. Input data will be partitioned for parallel processing. Each dataset in the list is partitioned into mini-batches separately, and each of the mini-batches is treated equally in the parallel processing.

output

Output port binding, may be used by later pipeline steps.

default value: None
side_inputs

List of side input reference data. Side inputs will not be partitioned as input data.

default value: None
arguments

List of command-line arguments to pass to the Python entry_script.

default value: None
allow_reuse

Whether the step should reuse previous results when run with the same settings/inputs. If this is false, a new run will always be generated for this step during pipeline execution.

default value: True
name
Required
str

Name of the step. Must be unique to the workspace, only consist of lowercase letters, numbers, or dashes, start with a letter, and be between 3 and 32 characters long.

parallel_run_config
Required

A ParallelRunConfig object used to determine required run properties.

inputs
Required

List of input datasets. All datasets in the list should be of same type. Input data will be partitioned for parallel processing. Each dataset in the list is partitioned into mini-batches separately, and each of the mini-batches is treated equally in the parallel processing.

output
Required

Output port binding, may be used by later pipeline steps.

side_inputs
Required

List of side input reference data. Side inputs will not be partitioned as input data.

arguments
Required

List of command-line arguments to pass to the Python entry_script.

allow_reuse
Required

Whether the step should reuse previous results when run with the same settings/inputs. If this is false, a new run will always be generated for this step during pipeline execution.

Remarks

ParallelRunStep can be used for processing large amounts of data in parallel. Common use cases are training an ML model or running offline inference to generate predictions on a batch of observations. ParallelRunStep works by breaking up your data into batches that are processed in parallel. The batch size node count, and other tunable parameters to speed up your parallel processing can be controlled with the ParallelRunConfig class. ParallelRunStep can work with either TabularDataset or FileDataset as input.

To use ParallelRunStep:

  • Create a ParallelRunConfig object to specify how batch processing is performed, with parameters to control batch size, number of nodes per compute target, and a reference to your custom Python script.

  • Create a ParallelRunStep object that uses the ParallelRunConfig object, define inputs and outputs for the step.

  • Use the configured ParallelRunStep object in a Pipeline just as you would with other pipeline step types.

Examples of working with ParallelRunStep and ParallelRunConfig classes for batch inference are discussed in the following articles:


   from azureml.pipeline.steps import ParallelRunStep, ParallelRunConfig

   parallel_run_config = ParallelRunConfig(
       source_directory=scripts_folder,
       entry_script=script_file,
       mini_batch_size="5",
       error_threshold=10,         # Optional, allowed failed count on mini batch items
       allowed_failed_count=15,    # Optional, allowed failed count on mini batches
       allowed_failed_percent=10,  # Optional, allowed failed percent on mini batches
       output_action="append_row",
       environment=batch_env,
       compute_target=compute_target,
       node_count=2)

   parallelrun_step = ParallelRunStep(
       name="predict-digits-mnist",
       parallel_run_config=parallel_run_config,
       inputs=[ named_mnist_ds ],
       output=output_dir,
       arguments=[ "--extra_arg", "example_value" ],
       allow_reuse=True
   )

For more information about this example, see the notebook https://aka.ms/batch-inference-notebooks.

Methods

create_module_def

Create the module definition object that describes the step.

This method is not intended to be used directly.

create_node

Create a node for PythonScriptStep and add it to the specified graph.

This method is not intended to be used directly. When a pipeline is instantiated with ParallelRunStep, Azure Machine Learning automatically passes the parameters required through this method so that the step can be added to a pipeline graph that represents the workflow.

create_module_def

Create the module definition object that describes the step.

This method is not intended to be used directly.

create_module_def(execution_type, input_bindings, output_bindings, param_defs=None, create_sequencing_ports=True, allow_reuse=True, version=None, arguments=None)

Parameters

Name Description
execution_type
Required
str

The execution type of the module.

input_bindings
Required

The step input bindings.

output_bindings
Required

The step output bindings.

param_defs

The step param definitions.

default value: None
create_sequencing_ports

If true, sequencing ports will be created for the module.

default value: True
allow_reuse

If true, the module will be available to be reused in future Pipelines.

default value: True
version
str

The version of the module.

default value: None
arguments

Annotated arguments list to use when calling this module.

default value: None

Returns

Type Description

The module def object.

create_node

Create a node for PythonScriptStep and add it to the specified graph.

This method is not intended to be used directly. When a pipeline is instantiated with ParallelRunStep, Azure Machine Learning automatically passes the parameters required through this method so that the step can be added to a pipeline graph that represents the workflow.

create_node(graph, default_datastore, context)

Parameters

Name Description
graph
Required

Graph object.

default_datastore
Required

Default datastore.

context
Required
<xref:azureml.pipeline.core._GraphContext>

Context.

Returns

Type Description

The created node.