@@ -422,9 +422,7 @@ def test_upsert_updates_existing_pipeline(self, mock_session):
422422 # Verify tags were merged and added
423423 mock_session .sagemaker_client .add_tags .assert_called_once ()
424424
425- def test_upsert_updates_existing_pipeline_with_names_must_be_unique_message (
426- self , mock_session
427- ):
425+ def test_upsert_updates_existing_pipeline_with_names_must_be_unique_message (self , mock_session ):
428426 """Upsert must also recognize the newer service wording 'names must be unique'."""
429427 error_response = {
430428 "Error" : {
@@ -436,11 +434,15 @@ def test_upsert_updates_existing_pipeline_with_names_must_be_unique_message(
436434 mock_session .sagemaker_client .list_tags = Mock (return_value = {"Tags" : []})
437435 mock_session .sagemaker_client .add_tags = Mock ()
438436
439- with patch .object (Pipeline , 'create' ) as mock_create :
440- with patch .object (Pipeline , 'update' ) as mock_update :
441- with patch ('sagemaker.mlops.workflow.pipeline.resolve_value_from_config' ) as mock_resolve :
442- with patch ('sagemaker.mlops.workflow.pipeline.resolve_and_validate_role' ) as mock_validate :
443- with patch ('sagemaker.mlops.workflow.pipeline.format_tags' ) as mock_format :
437+ with patch .object (Pipeline , "create" ) as mock_create :
438+ with patch .object (Pipeline , "update" ) as mock_update :
439+ with patch (
440+ "sagemaker.mlops.workflow.pipeline.resolve_value_from_config"
441+ ) as mock_resolve :
442+ with patch (
443+ "sagemaker.mlops.workflow.pipeline.resolve_and_validate_role"
444+ ) as mock_validate :
445+ with patch ("sagemaker.mlops.workflow.pipeline.format_tags" ) as mock_format :
444446 mock_resolve .return_value = "arn:aws:iam::123:role/SageMakerRole"
445447 mock_validate .return_value = "arn:aws:iam::123:role/SageMakerRole"
446448 mock_format .return_value = []
@@ -450,8 +452,7 @@ def test_upsert_updates_existing_pipeline_with_names_must_be_unique_message(
450452 }
451453
452454 pipeline = Pipeline (
453- name = "test-pipeline" ,
454- sagemaker_session = mock_session
455+ name = "test-pipeline" , sagemaker_session = mock_session
455456 )
456457
457458 result = pipeline .upsert (role_arn = "arn:aws:iam::123:role/SageMakerRole" )
@@ -475,11 +476,15 @@ def test_upsert_of_existing_pipeline_does_not_log_error_hint(self, mock_session,
475476 )
476477 mock_session .sagemaker_client .list_tags = Mock (return_value = {"Tags" : []})
477478
478- with patch .object (Pipeline , 'update' ) as mock_update :
479- with patch .object (Pipeline , '_create_args' ) as mock_args :
480- with patch ('sagemaker.mlops.workflow.pipeline.resolve_value_from_config' ) as mock_resolve :
481- with patch ('sagemaker.mlops.workflow.pipeline.resolve_and_validate_role' ) as mock_validate :
482- with patch ('sagemaker.mlops.workflow.pipeline.format_tags' ) as mock_format :
479+ with patch .object (Pipeline , "update" ) as mock_update :
480+ with patch .object (Pipeline , "_create_args" ) as mock_args :
481+ with patch (
482+ "sagemaker.mlops.workflow.pipeline.resolve_value_from_config"
483+ ) as mock_resolve :
484+ with patch (
485+ "sagemaker.mlops.workflow.pipeline.resolve_and_validate_role"
486+ ) as mock_validate :
487+ with patch ("sagemaker.mlops.workflow.pipeline.format_tags" ) as mock_format :
483488 mock_resolve .return_value = "arn:aws:iam::123:role/SageMakerRole"
484489 mock_validate .return_value = "arn:aws:iam::123:role/SageMakerRole"
485490 mock_format .return_value = []
@@ -489,12 +494,13 @@ def test_upsert_of_existing_pipeline_does_not_log_error_hint(self, mock_session,
489494 }
490495
491496 pipeline = Pipeline (
492- name = "test-pipeline" ,
493- sagemaker_session = mock_session
497+ name = "test-pipeline" , sagemaker_session = mock_session
494498 )
495499
496500 with caplog .at_level (logging .ERROR ):
497- result = pipeline .upsert (role_arn = "arn:aws:iam::123:role/SageMakerRole" )
501+ result = pipeline .upsert (
502+ role_arn = "arn:aws:iam::123:role/SageMakerRole"
503+ )
498504
499505 assert "PipelineArn" in result
500506 mock_update .assert_called_once ()
@@ -515,19 +521,20 @@ def test_bare_create_of_existing_pipeline_logs_error_hint(self, mock_session, ca
515521 side_effect = ClientError (error_response , "create_pipeline" )
516522 )
517523
518- with patch .object (Pipeline , '_create_args' ) as mock_args :
519- with patch ('sagemaker.mlops.workflow.pipeline.resolve_value_from_config' ) as mock_resolve :
520- with patch ('sagemaker.mlops.workflow.pipeline.resolve_and_validate_role' ) as mock_validate :
521- with patch ('sagemaker.mlops.workflow.pipeline.format_tags' ) as mock_format :
524+ with patch .object (Pipeline , "_create_args" ) as mock_args :
525+ with patch (
526+ "sagemaker.mlops.workflow.pipeline.resolve_value_from_config"
527+ ) as mock_resolve :
528+ with patch (
529+ "sagemaker.mlops.workflow.pipeline.resolve_and_validate_role"
530+ ) as mock_validate :
531+ with patch ("sagemaker.mlops.workflow.pipeline.format_tags" ) as mock_format :
522532 mock_resolve .return_value = "arn:aws:iam::123:role/SageMakerRole"
523533 mock_validate .return_value = "arn:aws:iam::123:role/SageMakerRole"
524534 mock_format .return_value = []
525535 mock_args .return_value = {"PipelineName" : "test-pipeline" }
526536
527- pipeline = Pipeline (
528- name = "test-pipeline" ,
529- sagemaker_session = mock_session
530- )
537+ pipeline = Pipeline (name = "test-pipeline" , sagemaker_session = mock_session )
531538
532539 with caplog .at_level (logging .ERROR ):
533540 with pytest .raises (ClientError ):
0 commit comments