@@ -425,6 +425,19 @@ def test_pipeline_start(sagemaker_session_mock):
425425 PipelineName = "MyPipeline" , PipelineParameters = [{"Name" : "alpha" , "Value" : "epsilon" }]
426426 )
427427
428+
429+ def test_pipeline_start_selective_execution (sagemaker_session_mock ):
430+ sagemaker_session_mock .sagemaker_client .start_pipeline_execution .return_value = {
431+ "PipelineExecutionArn" : "my:arn"
432+ }
433+ pipeline = Pipeline (
434+ name = "MyPipeline" ,
435+ parameters = [],
436+ steps = [],
437+ sagemaker_session = sagemaker_session_mock ,
438+ )
439+
440+ # Case 1: Happy path
428441 selective_execution_config = SelectiveExecutionConfig (
429442 source_pipeline_execution_arn = "foo-arn" , selected_steps = ["step-1" , "step-2" , "step-3" ]
430443 )
@@ -441,6 +454,37 @@ def test_pipeline_start(sagemaker_session_mock):
441454 },
442455 )
443456
457+ # Case 2: Start selective execution without SourcePipelineExecutionArn
458+ sagemaker_session_mock .sagemaker_client .list_pipeline_executions .return_value = {
459+ "PipelineExecutionSummaries" : [
460+ {
461+ "PipelineExecutionArn" : "my:latest:execution:arn" ,
462+ "PipelineExecutionDisplayName" : "Latest" ,
463+ }
464+ ]
465+ }
466+ selective_execution_config = SelectiveExecutionConfig (
467+ selected_steps = ["step-1" , "step-2" , "step-3" ]
468+ )
469+ pipeline .start (selective_execution_config = selective_execution_config )
470+ sagemaker_session_mock .sagemaker_client .list_pipeline_executions .assert_called_with (
471+ PipelineName = "MyPipeline" ,
472+ SortBy = "CreationTime" ,
473+ SortOrder = "Descending" ,
474+ MaxResults = 1 ,
475+ )
476+ sagemaker_session_mock .sagemaker_client .start_pipeline_execution .assert_called_with (
477+ PipelineName = "MyPipeline" ,
478+ SelectiveExecutionConfig = {
479+ "SelectedSteps" : [
480+ {"StepName" : "step-1" },
481+ {"StepName" : "step-2" },
482+ {"StepName" : "step-3" },
483+ ],
484+ "SourcePipelineExecutionArn" : "my:latest:execution:arn" ,
485+ },
486+ )
487+
444488
445489def test_pipeline_basic ():
446490 parameter = ParameterString ("MyStr" )
0 commit comments