Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sagemaker-mlops/src/sagemaker/mlops/workflow/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,12 @@ def wait(self, delay=30, max_attempts=60):
"state": "failure",
"argument": "PipelineExecutionStatus",
},
{
"expected": "Stopped",
"matcher": "path",
"state": "failure",
"argument": "PipelineExecutionStatus",
},
],
}
},
Expand Down
27 changes: 27 additions & 0 deletions sagemaker-mlops/tests/unit/workflow/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,33 @@ def test_pipeline_execution_wait(mock_session):
mock_waiter.return_value.wait.assert_called_once()


@pytest.mark.parametrize("status", ["Failed", "Stopped"])
def test_pipeline_execution_wait_stops_on_terminal_failure(mock_session, status):
import boto3
from botocore.exceptions import WaiterError
from botocore.stub import Stubber
from sagemaker.mlops.workflow.pipeline import PipelineExecution

client = boto3.client(
"sagemaker",
region_name="us-west-2",
aws_access_key_id="testing",
aws_secret_access_key="testing",
)
mock_session.sagemaker_client = client
execution = PipelineExecution(arn="arn", sagemaker_session=mock_session)

with Stubber(client) as stubber:
stubber.add_response(
"describe_pipeline_execution",
{"PipelineExecutionStatus": status},
{"PipelineExecutionArn": "arn"},
)
with pytest.raises(WaiterError, match="terminal failure state"):
execution.wait(delay=0, max_attempts=3)
stubber.assert_no_pending_responses()


def test_get_function_step_result_invalid_step(mock_session):
from sagemaker.mlops.workflow.pipeline import get_function_step_result

Expand Down
Loading