PortDataReference Class
Models data associated with an output of a completed StepRun.
A PortDataReference object can be used to download the output data which was produced by a StepRun. It can also be used as an step input in a future Pipeline.
Initialize PortDataReference.
- Inheritance
-
builtins.objectPortDataReference
Constructor
PortDataReference(context, pipeline_run_id, data_reference, step_run=None)
Parameters
Name | Description |
---|---|
context
Required
|
<xref:azureml.pipeline.core._GraphContext>
The graph context object. |
pipeline_run_id
Required
|
The id of the pipeline run which produced the output. |
data_reference
Required
|
The data reference object. |
step_run
|
The StepRun object which produced the data. Default value: None
|
context
Required
|
<xref:azureml.pipeline.core._GraphContext>
The graph context object. |
pipeline_run_id
Required
|
The id of the pipeline run which produced the output. |
data_reference
Required
|
The data reference object. |
step_run
Required
|
The StepRun object which produced the data. |
Remarks
A PortDataReference points to data which was produced by a completed StepRun.
Get a PortDataReference from a PipelineRun and download the output data as follows:
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")
A PortDataReference can be used as an input to a step in a Pipeline, similar to using a DataReference.
An example to using a PortDataReference as a step input is as follows:
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])
In this example, the newly constructed Pipeline will use the output which was created by the completed PipelineRun as an input to the train step.
Methods
as_download |
Consume the PortDataReference as a step input through the "download" mode. |
as_input |
Create an InputPortBinding and specify an input name (but use default mode). |
as_mount |
Consume the PortDataReference as a step input through the "mount" mode. |
create_input_binding |
Create input binding with this PortDataReference as the source. |
download |
Download the data represented by the PortDataReference. |
as_download
Consume the PortDataReference as a step input through the "download" mode.
as_download(input_name=None, path_on_compute=None, overwrite=None)
Parameters
Name | Description |
---|---|
input_name
|
Specify a name for this input. Default value: None
|
path_on_compute
|
The path on the compute to download the data to. Default value: None
|
overwrite
|
Use to indicate whether to overwrite existing data. Default value: None
|
Returns
Type | Description |
---|---|
The InputPortBinding with this PortDataReference as the source. |
as_input
Create an InputPortBinding and specify an input name (but use default mode).
as_input(input_name)
Parameters
Name | Description |
---|---|
input_name
Required
|
Use to specify a name for this input. |
Returns
Type | Description |
---|---|
The InputPortBinding with this PortDataReference as the source. |
as_mount
Consume the PortDataReference as a step input through the "mount" mode.
as_mount(input_name=None)
Parameters
Name | Description |
---|---|
input_name
|
Use to specify a name for this input. Default value: None
|
Returns
Type | Description |
---|---|
The InputPortBinding with this PortDataReference as the source. |
create_input_binding
Create input binding with this PortDataReference as the source.
create_input_binding(input_name=None, mode=None, path_on_compute=None, overwrite=None)
Parameters
Name | Description |
---|---|
input_name
|
The name of the input. Default value: None
|
mode
|
The mode to access the PortDataReference ("mount" or "download"). Default value: None
|
path_on_compute
|
For "download" mode, the path on the compute the data will reside. Default value: None
|
overwrite
|
For "download" mode, whether to overwrite existing data. Default value: None
|
Returns
Type | Description |
---|---|
The InputPortBinding with this PortDataReference as the source. |
download
Download the data represented by the PortDataReference.
download(local_path, overwrite=None, show_progress=None)
Parameters
Name | Description |
---|---|
local_path
Required
|
Local path to download to. |
overwrite
|
If true, overwrite existing file, defaults to False. Default value: None
|
show_progress
|
Show the progress of download in the console, defaults to True. Default value: None
|
Returns
Type | Description |
---|---|
The number of files successfully downloaded. |
Attributes
datastore
Get the Datastore associated with the PortDataReference.
Returns
Type | Description |
---|---|
The datastore object. |
datastore_name
Get the name of the Datastore associated with the PortDataReference.
Returns
Type | Description |
---|---|
The datastore name. |
name
path_on_datastore
Get the path on datastore for the PortDataReference.
Returns
Type | Description |
---|---|
The path on datastore. |