StepRun class

Definition

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.

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)
Inheritance
azureml._run_impl.run_base._RunBase
StepRun

Parameters

experiment
Experiment

The experiment object of the step run.

step_run_id
str

The run ID of the step run.

pipeline_run_id
str

The run ID of the parent pipeline run.

node_id
str

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

_service_endpoint
str

The endpoint to connect to.

_is_reused
bool

Indicates whether this run is a reused previous run.

_current_node_id
str

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

_reused_run_id
str

The reused run ID.

_reused_node_id
str

The reused node ID.

_reused_pipeline_run_id
str

The reused pipeline ID.

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(name) to retrieve the single StepRunOutput object for the output with the provided name. You can also use get_output_data(name) 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(name=None, run_id=None, outputs=None)

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(name)

Get the node output with the given name.

get_output_data(name)

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(show_output=True, timeout_seconds=9223372036854775807, raise_on_error=True)

Wait for the completion of this step run.

Returns the status after the wait.

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

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

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

Parameters

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

The child run

Return type

Run

complete()

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

complete()

fail()

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

fail()

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

get_job_log()

Dump the current job log for the step run.

get_job_log()

Returns

The log string.

Return type

str

get_output(name)

Get the node output with the given name.

get_output(name)

Parameters

name
str

Name of the output.

Returns

The StepRunOutput with the given name.

Return type

get_output_data(name)

Get the output data from a given output.

get_output_data(name)

Parameters

name
str

Name of the output.

Returns

The PortDataReference representing the step output data.

Return type

get_outputs()

Get the step outputs.

get_outputs()

Returns

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

Return type

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

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

get_stdout_log()

Dump the current stdout log for the step run.

get_stdout_log()

Returns

The log string.

Return type

str

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

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

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

default value: True
timeout_seconds
int

Number of seconds to wait before timing out.

default value: 9223372036854775807
raise_on_error
bool

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

default value: True

Returns

The final status.

Return type

str

Attributes

pipeline_run_id

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

Returns

The PipelineRun id.

Return type

str