StepRun Class

A run of a step in a Pipeline.

This class can be used to manage, check status, and retrieve run details once the parent pipeline run is submitted and the pipeline has submitted the step run.

Initialize a StepRun.

Inheritance
StepRun

Constructor

StepRun(experiment, step_run_id, pipeline_run_id, node_id, _service_endpoint=None, _is_reused=False, _current_node_id=None, _reused_run_id=None, _reused_node_id=None, _reused_pipeline_run_id=None, **kwargs)

Parameters

experiment
Experiment
Required

The experiment object of the step run.

step_run_id
str
Required

The run ID of the step run.

pipeline_run_id
str
Required

The run ID of the parent pipeline run.

node_id
str
Required

The ID of the node in the graph that represents this step.

_service_endpoint
str
default value: None

The endpoint to connect to.

_is_reused
bool
default value: False

Indicates whether this run is a reused previous run.

_current_node_id
str
default value: None

For a reused node, the node ID on the current graph.

_reused_run_id
str
default value: None

The reused run ID.

_reused_node_id
str
default value: None

The reused node ID.

_reused_pipeline_run_id
str
default value: None

The reused pipeline ID.

experiment
Experiment
Required

The experiment object of the step run.

step_run_id
str
Required

The run ID of the step run.

pipeline_run_id
str
Required

The run ID of the parent pipeline run.

node_id
str
Required

The ID of the node in the graph that represents this step.

_service_endpoint
str
Required

The endpoint to connect to.

_is_reused
bool
Required

Indicates whether this run is a reused previous run.

_current_node_id
str
Required

For a reused node, the node ID on the current graph.

_reused_run_id
Required
_reused_node_id
str
Required
_reused_pipeline_run_id
str
Required

Remarks

A StepRun is created as a child run of a submitted PipelineRun. Fetch all the StepRuns in a PipelineRun 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>")
   step_runs = pipeline_run.get_steps()

Use get_details_with_logs to fetch the run details and logs created by the run.

StepRun can also be used to download the outputs of a run. Use get_outputs to retrieve a dict of the step outputs, or use get_output to retrieve the single StepRunOutput object for the output with the provided name. You can also use get_output_data to fetch the PortDataReference for the specified step output directly.

An example of downloading a step output is as follows:


   from azureml.pipeline.core import PipelineRun, StepRun, PortDataReference

   pipeline_run = PipelineRun(experiment, "<pipeline_run_id>")
   step_run = pipeline_run.find_step_run("<step_name>")[0]
   port_data_reference = step_run.get_output_data("<output_name>")
   port_data_reference.download(local_path="path")

Methods

child_run

Child run for step run. This method is not implemented for StepRun.

complete

Complete for step run. This method is not implemented for StepRun.

fail

Fail for step run. This method is not implemented for StepRun.

get_details_with_logs

Return the status details of the run with log file contents.

get_job_log

Dump the current job log for the step run.

get_output

Get the node output with the given name.

get_output_data

Get the output data from a given output.

get_outputs

Get the step outputs.

get_status

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

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

get_stderr_log

Dump the current stderr log for the step run.

get_stdout_log

Dump the current stdout log for the step run.

wait_for_completion

Wait for the completion of this step run.

Returns the status after the wait.

child_run

Child run for step run. This method is not implemented for StepRun.

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

Parameters

name
str
default value: None

Optional name for the child

run_id
str
default value: None

Optional run_id for the child, otherwise uses default

outputs
str
default value: None

Optional outputs directory to track for the child

Returns

The child run

Return type

Run

Exceptions

complete

Complete for step run. This method is not implemented for StepRun.

complete()

Exceptions

fail

Fail for step run. This method is not implemented for StepRun.

fail()

Exceptions

get_details_with_logs

Return the status details of the run with log file contents.

get_details_with_logs()

Returns

Returns the status for the run with log file contents

Return type

Exceptions

get_job_log

Dump the current job log for the step run.

get_job_log()

Returns

The log string.

Return type

str

Exceptions

get_output

Get the node output with the given name.

get_output(name)

Parameters

name
str
Required

Name of the output.

Returns

The StepRunOutput with the given name.

Return type

Exceptions

get_output_data

Get the output data from a given output.

get_output_data(name)

Parameters

name
str
Required

Name of the output.

Returns

The PortDataReference representing the step output data.

Return type

Exceptions

get_outputs

Get the step outputs.

get_outputs()

Returns

A dictionary of StepRunOutputs with the output name as the key.

Return type

Exceptions

get_status

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

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

get_status()

Returns

The latest status as a string

Return type

str

Exceptions

Remarks

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

  • Queued - The job is queued.

  • 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_stderr_log

Dump the current stderr log for the step run.

get_stderr_log()

Returns

The log string.

Return type

str

Exceptions

get_stdout_log

Dump the current stdout log for the step run.

get_stdout_log()

Returns

The log string.

Return type

str

Exceptions

wait_for_completion

Wait for the completion of this step run.

Returns the status after the wait.

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

Parameters

show_output
bool
default value: True

show_output=True shows the pipeline run status on sys.stdout.

timeout_seconds
int
default value: 9223372036854775807

Number of seconds to wait before timing out.

raise_on_error
bool
default value: True

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

Returns

The final status.

Return type

str

Exceptions

Attributes

pipeline_run_id

Return the id of the pipeline run corresponding to this step run.

Returns

The PipelineRun id.

Return type

str