InputPortBinding Class

Defines a binding from a source to an input of a pipeline step.

An InputPortBinding can be used as an input to a step. The source can be a PipelineData, PortDataReference, DataReference, PipelineDataset, or OutputPortBinding.

InputPortBinding is useful to specify the name of the step input, if it should be different than the name of the bind object (i.e. to avoid duplicate input/output names or because the step script needs an input to have a certain name). It can also be used to specify the bind_mode for PythonScriptStep inputs.

Initialize InputPortBinding.

Inheritance
builtins.object
InputPortBinding

Constructor

InputPortBinding(name, bind_object=None, bind_mode='mount', path_on_compute=None, overwrite=None, is_resource=False, additional_transformations=None, **kwargs)

Parameters

Name Description
name
Required
str

Name of the input port to bind, which can contain only letters, digits, and underscores.

bind_object

The object to bind to the input port.

default value: None
bind_mode
str

Specifies whether the consuming step will use "download" or "mount" method to access the data.

default value: mount
path_on_compute
str

For "download" mode, the local path the step will read the data from.

default value: None
overwrite

For "download" mode, indicate whether to overwrite existing data.

default value: None
is_resource

Indicated whether input is a resource. Resources are downloaded to the script folder and provide a way to change the behavior of script at run-time.

default value: False
additional_transformations
<xref:azureml.dataprep.Dataflow>

Additional transformations to apply to the input. This will only be applied if the output of the previous step is an Azure Machine Learning Dataset.

default value: None
name
Required
str

Name of the input port to bind, which can contain only letters, digits, and underscores.

bind_object
Required

The object to bind to the input port.

bind_mode
Required
str

Specifies whether the consuming step will use "download" or "mount" or "direct" method to access the data.

path_on_compute
Required
str

For "download" mode, the local path the step will read the data from.

overwrite
Required

For "download" mode, indicate whether to overwrite existing data.

is_resource
Required

Indicate whether input is a resource. Resources are downloaded to the script folder and provide a way to change the behavior of script at run-time.

additional_transformations
Required
<xref:azureml.dataprep.Dataflow>

Additional transformations to apply to the input. This will only be applied if the output of the previous step is an Azure Machine Learning Dataset.

Remarks

InputPortBinding is used to specify data dependencies in a Pipeline, it represents an input which a step requires for execution. InputPortBindings have a source, called bind_object, which specifies how the input data is produced.

PipelineData and OutputPortBinding can be used as the bind_object for an InputPortBinding to specify that the input to the step will be produced by another step in the Pipeline.

An example to build a Pipeline using InputPortBinding and PipelineData is as follows:


   from azureml.pipeline.core import PipelineData, InputPortBinding, Pipeline
   from azureml.pipeline.steps import PythonScriptStep

   step_1_output = PipelineData("output", datastore=datastore, output_mode="mount")

   step_1 = PythonScriptStep(
       name='prepare data',
       script_name="prepare_data.py",
       compute_target=compute,
       arguments=["--output", step_1_output],
       outputs=[step_1_output]
   )

   step_2_input = InputPortBinding("input", bind_object=step_1_output)

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

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

In this example the "train" step requires the output of the "prepare data" step as an input.

PortDataReference, DataReference, or PipelineDataset can be used as the bind_object for an InputPortBinding to specify that the input to the step already exists at a specified location.

An example to build a Pipeline using InputPortBinding and DataReference is as follows:


   from azureml.data.data_reference import DataReference
   from azureml.pipeline.core import InputPortBinding, Pipeline
   from azureml.pipeline.steps import PythonScriptStep

   data_reference = DataReference(datastore=datastore, path_on_datastore='sample_data.txt', mode="mount")
   step_1_input = InputPortBinding("input", bind_object=data_reference)

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

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

In this example the "train" step requires the "sample_data.txt" file specified by the DataReference as an input.

Methods

as_resource

Get a duplicate input port binding which can be used as a resource.

get_bind_object_data_type

Get the data type of the bind object.

get_bind_object_name

Get the name of the bind object.

as_resource

Get a duplicate input port binding which can be used as a resource.

as_resource()

Returns

Type Description

InputPortBinding with is_resource property set a True.

get_bind_object_data_type

Get the data type of the bind object.

get_bind_object_data_type()

Returns

Type Description
str

The data type name.

get_bind_object_name

Get the name of the bind object.

get_bind_object_name()

Returns

Type Description
str

The bind object name.

Attributes

additional_transformations

Get the additional transformations to apply to the input data.

Returns

Type Description
<xref:azureml.dataprep.Dataflow>

The additional transformations to apply to the input data.

bind_mode

Get the mode ("download" or "mount" or "direct", "hdfs") the consuming step will use to access the data.

Returns

Type Description
str

The bind mode ("download" or "mount" or "direct" or "hdfs").

bind_object

Get the object the InputPort will be bound to.

Returns

Type Description

The bind object.

data_reference_name

Get the name of the data reference associated with the InputPortBinding.

Returns

Type Description
str

The data reference name.

data_type

Get the type of the input data.

Returns

Type Description
str

The data type property.

is_resource

Get whether input is a resource.

Returns

Type Description

Is input a resource.

name

Name of the Input port binding.

Returns

Type Description
str

The name.

overwrite

For "download" mode, indicate whether to overwrite existing data.

Returns

Type Description

The overwrite property.

path_on_compute

Get the local path the step will read the data from.

Returns

Type Description
str

The path on compute.