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
Name | Description |
---|---|
experiment
Required
|
The experiment object of the step run. |
step_run_id
Required
|
The run ID of the step run. |
pipeline_run_id
Required
|
The run ID of the parent pipeline run. |
node_id
Required
|
The ID of the node in the graph that represents this step. |
_service_endpoint
|
The endpoint to connect to. Default value: None
|
_is_reused
|
Indicates whether this run is a reused previous run. Default value: False
|
_current_node_id
|
For a reused node, the node ID on the current graph. Default value: None
|
_reused_run_id
|
The reused run ID. Default value: None
|
_reused_node_id
|
The reused node ID. Default value: None
|
_reused_pipeline_run_id
|
The reused pipeline ID. Default value: None
|
experiment
Required
|
The experiment object of the step run. |
step_run_id
Required
|
The run ID of the step run. |
pipeline_run_id
Required
|
The run ID of the parent pipeline run. |
node_id
Required
|
The ID of the node in the graph that represents this step. |
_service_endpoint
Required
|
The endpoint to connect to. |
_is_reused
Required
|
Indicates whether this run is a reused previous run. |
_current_node_id
Required
|
For a reused node, the node ID on the current graph. |
_reused_run_id
Required
|
|
_reused_node_id
Required
|
|
_reused_pipeline_run_id
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 | Description |
---|---|
name
|
Optional name for the child Default value: None
|
run_id
|
Optional run_id for the child, otherwise uses default Default value: None
|
outputs
|
Optional outputs directory to track for the child Default value: None
|
Returns
Type | Description |
---|---|
The child run |
Exceptions
Type | Description |
---|---|
complete
Complete for step run. This method is not implemented for StepRun.
complete()
Exceptions
Type | Description |
---|---|
fail
Fail for step run. This method is not implemented for StepRun.
fail()
Exceptions
Type | Description |
---|---|
get_details_with_logs
Return the status details of the run with log file contents.
get_details_with_logs()
Returns
Type | Description |
---|---|
Returns the status for the run with log file contents |
Exceptions
Type | Description |
---|---|
get_job_log
Dump the current job log for the step run.
get_job_log()
Returns
Type | Description |
---|---|
The log string. |
Exceptions
Type | Description |
---|---|
get_output
Get the node output with the given name.
get_output(name)
Parameters
Name | Description |
---|---|
name
Required
|
Name of the output. |
Returns
Type | Description |
---|---|
The StepRunOutput with the given name. |
Exceptions
Type | Description |
---|---|
get_output_data
Get the output data from a given output.
get_output_data(name)
Parameters
Name | Description |
---|---|
name
Required
|
Name of the output. |
Returns
Type | Description |
---|---|
The PortDataReference representing the step output data. |
Exceptions
Type | Description |
---|---|
get_outputs
Get the step outputs.
get_outputs()
Returns
Type | Description |
---|---|
A dictionary of StepRunOutputs with the output name as the key. |
Exceptions
Type | Description |
---|---|
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 |
---|---|
The latest status as a string |
Exceptions
Type | Description |
---|---|
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
Type | Description |
---|---|
The log string. |
Exceptions
Type | Description |
---|---|
get_stdout_log
Dump the current stdout log for the step run.
get_stdout_log()
Returns
Type | Description |
---|---|
The log string. |
Exceptions
Type | Description |
---|---|
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
Name | Description |
---|---|
show_output
|
show_output=True shows the pipeline run status on sys.stdout. Default value: True
|
timeout_seconds
|
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 |
---|---|
The final status. |
Exceptions
Type | Description |
---|---|
Attributes
pipeline_run_id
Return the id of the pipeline run corresponding to this step run.
Returns
Type | Description |
---|---|
The PipelineRun id. |