PipelineRun Class

Represents a run of a Pipeline.

This class can be used to manage, check status, and retrieve run details once a pipeline run is submitted. Use get_steps to retrieve the StepRun objects which are created by the pipeline run. Other uses include retrieving the Graph object associated with the pipeline run, fetching the status of the pipeline run, and waiting for run completion.

Initialize a Pipeline run.

Inheritance
PipelineRun

Constructor

PipelineRun(experiment, run_id, _service_endpoint=None, **kwags)

Parameters

Name Description
experiment
Required

The experiment object associated with the pipeline run.

run_id
Required
str

The run ID of the pipeline run.

_service_endpoint
str

The endpoint to connect to.

Default value: None
experiment
Required

The experiment object associated with the pipeline run.

run_id
Required
str

The run ID of the pipeline run.

_service_endpoint
Required
str

The endpoint to connect to.

Remarks

A PipelineRun object is returned when submitting a Pipeline through the submit. method of an Experiment. For more information on how to create and submit a Pipeline see: https://aka.ms/pl-first-pipeline.

A PipelineRun can also be instantiated with the Experiment the run was submitted to and the PipelineRun ID as follows:


   from azureml.core import Experiment
   from azureml.pipeline.core import PipelineRun

   experiment = Experiment(workspace, "<experiment_name>")
   pipeline_run = PipelineRun(experiment, "<pipeline_run_id>")

When working with PipelineRun use:

  • wait_for_completion to monitor the run status and optionally stream run logs.

  • get_status to fetch the run status.

  • cancel to cancel an ongoing PipelineRun.

  • get_steps to list the generated StepRuns. A PipelineRun generates a StepRun for each step in the Pipeline.

Methods

cancel

Cancel the ongoing run.

child_run

Create a child run for the pipeline run. This method is not implemented for PipelineRun.

complete

Mark the pipeline run as complete. This method is not implemented for PipelineRun.

This method is not supported for pipelines; completion/failed status is managed by the Azure ML backend.

fail

Mark the the pipeline run as failed. This method is not implemented for PipelineRun.

This method is not supported for pipelines; completion/failed status is managed by the Azure ML backend.

find_step_run

Find a step run in the pipeline by name.

get

Fetch a pipeline run based on a run ID.

get_graph

Get the graph of the pipeline run.

get_pipeline_output

Get the PortDataReference for the given pipeline output.

get_pipeline_runs

Fetch the pipeline runs that were generated from a published pipeline.

get_status

Fetch the pipeline run's latest status from the service.

Common values returned include "Running", "Finished", and "Failed".

get_steps

Get the step runs for all pipeline steps that have completed or started running.

get_tags

Get the set of tags for the run.

publish_pipeline

Publish a pipeline and make it available for rerunning.

You can get the pipeline endpoint from the PublishedPipeline object returned by this function. With the pipeline endpoint, you can invoke the pipeline from external applications using REST calls. For information about how to authenticate when calling REST endpoints, see https://aka.ms/pl-restep-auth.

The original pipeline associated with the pipeline run is used as the base for the published pipeline.

save

Save the pipeline YAML to a file.

wait_for_completion

Wait for the completion of this pipeline run.

Returns the status after the wait.

cancel

Cancel the ongoing run.

cancel()

child_run

Create a child run for the pipeline run. This method is not implemented for PipelineRun.

child_run(name=None, run_id=None, outputs=None)

Parameters

Name Description
name
str

Optional name for the child.

Default value: None
run_id
str

Optional run ID for the child, otherwise uses default.

Default value: None
outputs
str

Optional outputs directory to track for the child.

Default value: None

Returns

Type Description
Run

The child run.

Exceptions

Type Description

complete

Mark the pipeline run as complete. This method is not implemented for PipelineRun.

This method is not supported for pipelines; completion/failed status is managed by the Azure ML backend.

complete()

Exceptions

Type Description

fail

Mark the the pipeline run as failed. This method is not implemented for PipelineRun.

This method is not supported for pipelines; completion/failed status is managed by the Azure ML backend.

fail()

Exceptions

Type Description

find_step_run

Find a step run in the pipeline by name.

find_step_run(name)

Parameters

Name Description
name
Required
str

The name of the step to find.

Returns

Type Description

List of StepRun objects with the provided name.

get

Fetch a pipeline run based on a run ID.

static get(workspace, run_id, _service_endpoint=None)

Parameters

Name Description
workspace
Required

The workspace associated with the pipeline.

run_id
Required
str

The ID of the pipeline run.

_service_endpoint
str

The endpoint to connect to.

Default value: None

Returns

Type Description

The PipelineRun object.

get_graph

Get the graph of the pipeline run.

get_graph()

Returns

Type Description

The graph.

get_pipeline_output

Get the PortDataReference for the given pipeline output.

get_pipeline_output(pipeline_output_name)

Parameters

Name Description
pipeline_output_name
Required
str

The name of the pipeline output to get.

Returns

Type Description

The PortDataReference representing the pipeline output data.

get_pipeline_runs

Fetch the pipeline runs that were generated from a published pipeline.

static get_pipeline_runs(workspace, pipeline_id, _service_endpoint=None)

Parameters

Name Description
workspace
Required

The workspace associated with the pipeline.

pipeline_id
Required
str

The ID of the published pipeline.

_service_endpoint
str

The endpoint to connect to.

Default value: None

Returns

Type Description

A list of PipelineRun objects.

get_status

Fetch the pipeline run's latest status from the service.

Common values returned include "Running", "Finished", and "Failed".

get_status()

Returns

Type Description
str

The latest status as a string.

Remarks

  • NotStarted - This is a temporary state client-side Run objects are in before cloud submission

  • Running - The job started to run in the compute target.

  • Failed - The run failed. Usually the Error property on a run will provide details as to why.

  • Finished - The run completed successfully.

  • Canceled - Following cancellation request, the run is now successfully cancelled.


   run = experiment.submit(config)
   while run.get_status() not in ['Finished', 'Failed']: # For example purposes only, not exhaustive
       print('Run {} not in terminal state'.format(run.id))
       time.sleep(10)

get_steps

Get the step runs for all pipeline steps that have completed or started running.

get_steps()

Returns

Type Description

A list of StepRun objects.

get_tags

Get the set of tags for the run.

get_tags()

Returns

Type Description

The dictionary of tags for the run.

publish_pipeline

Publish a pipeline and make it available for rerunning.

You can get the pipeline endpoint from the PublishedPipeline object returned by this function. With the pipeline endpoint, you can invoke the pipeline from external applications using REST calls. For information about how to authenticate when calling REST endpoints, see https://aka.ms/pl-restep-auth.

The original pipeline associated with the pipeline run is used as the base for the published pipeline.

publish_pipeline(name, description, version, continue_on_step_failure=None, **kwargs)

Parameters

Name Description
name
Required
str

The name of the published pipeline.

description
Required
str

The description of the published pipeline.

version
Required
str

The version of the published pipeline.

continue_on_step_failure

Whether to continue execution of other steps in the PipelineRun if a step fails. The default is False.

Default value: None
kwargs
Required

Custom keyword arguments, reserved for future development

Returns

Type Description

Created published pipeline.

save

Save the pipeline YAML to a file.

save(path=None)

Parameters

Name Description
path
str

The path to save the YAML to. If the path is a directory, the pipeline YAML file is saved at <path>/pipeline.yml. If path is none, the current directory is used.

Default value: None

Returns

Type Description

wait_for_completion

Wait for the completion of this pipeline run.

Returns the status after the wait.

wait_for_completion(show_output=True, timeout_seconds=9223372036854775807, raise_on_error=True)

Parameters

Name Description
show_output

Indicates whether to show the pipeline run status on sys.stdout.

Default value: True
timeout_seconds
int

The number of seconds to wait before timing out.

Default value: 9223372036854775807
raise_on_error

Indicates whether to raise an error when the run is in a failed state.

Default value: True

Returns

Type Description
str

The final status.