File tree Expand file tree Collapse file tree 2 files changed +37
-13
lines changed
google/cloud/aiplatform/_pipeline_based_service Expand file tree Collapse file tree 2 files changed +37
-13
lines changed Original file line number Diff line number Diff line change @@ -391,13 +391,21 @@ def list(
391391
392392 for pipeline_execution in filtered_pipeline_executions :
393393 if "pipeline_job_resource_name" in pipeline_execution .metadata :
394- service_pipeline_job = cls (
395- pipeline_execution .metadata ["pipeline_job_resource_name" ],
396- project = project ,
397- location = location ,
398- credentials = credentials ,
399- )
400- service_pipeline_jobs .append (service_pipeline_job )
394+ # This is wrapped in a try/except for cases when both
395+ # `_coponent_identifier` and `_template_name_identifier` are
396+ # set. In that case, even though all pipelines returned by the
397+ # Execution.list() call will match the `_component_identifier`,
398+ # some may not match the `_template_name_identifier`
399+ try :
400+ service_pipeline_job = cls (
401+ pipeline_execution .metadata ["pipeline_job_resource_name" ],
402+ project = project ,
403+ location = location ,
404+ credentials = credentials ,
405+ )
406+ service_pipeline_jobs .append (service_pipeline_job )
407+ except ValueError :
408+ continue
401409
402410 return service_pipeline_jobs
403411
Original file line number Diff line number Diff line change @@ -596,15 +596,9 @@ def test_create_and_submit_pipeline_job(
596596 == test_backing_pipeline_job .resource_name
597597 )
598598
599- @pytest .mark .parametrize (
600- "job_spec_json" ,
601- [_TEST_PIPELINE_JOB ],
602- )
603599 def test_list_pipeline_based_service (
604600 self ,
605601 mock_pipeline_based_service_get ,
606- mock_load_yaml_and_json ,
607- job_spec_json ,
608602 get_execution_mock ,
609603 list_executions_mock ,
610604 ):
@@ -635,3 +629,25 @@ def test_list_pipeline_based_service(
635629 # only 1 of the 2 executions in list_executions_mock matches the
636630 # properties of FakePipelineBasedService
637631 assert len (test_list_request ) == 1
632+
633+ def test_list_pipeline_based_service_with_template_name_identifier (
634+ self ,
635+ mock_pipeline_based_service_get ,
636+ get_execution_mock ,
637+ list_executions_mock ,
638+ ):
639+ aiplatform .init (
640+ project = _TEST_PROJECT ,
641+ location = _TEST_LOCATION ,
642+ credentials = _TEST_CREDENTIALS ,
643+ )
644+
645+ self .FakePipelineBasedService ._template_name_identifier = (
646+ _TEST_INVALID_PIPELINE_NAME_IDENTIFIER
647+ )
648+
649+ test_list_request = self .FakePipelineBasedService .list ()
650+
651+ # None of the mock pipelines match the `_template_name_identifier`
652+ # set above, so the returned list should be empty
653+ assert len (test_list_request ) == 0
You can’t perform that action at this time.
0 commit comments