@@ -1567,6 +1567,61 @@ def test_pipeline_failure_raises(self, mock_load_yaml_and_json, sync):
15671567 if not sync :
15681568 job .wait ()
15691569
1570+ @pytest .mark .usefixtures (
1571+ "mock_pipeline_service_create" ,
1572+ "mock_pipeline_service_get_with_fail" ,
1573+ "mock_pipeline_bucket_exists" ,
1574+ )
1575+ @pytest .mark .parametrize (
1576+ "job_spec" ,
1577+ [_TEST_PIPELINE_SPEC_JSON , _TEST_PIPELINE_SPEC_YAML , _TEST_PIPELINE_JOB ],
1578+ )
1579+ def test_pipeline_job_has_failed_property (self , mock_load_yaml_and_json ):
1580+ aiplatform .init (
1581+ project = _TEST_PROJECT ,
1582+ staging_bucket = _TEST_GCS_BUCKET_NAME ,
1583+ location = _TEST_LOCATION ,
1584+ credentials = _TEST_CREDENTIALS ,
1585+ )
1586+
1587+ job = pipeline_jobs .PipelineJob (
1588+ display_name = _TEST_PIPELINE_JOB_DISPLAY_NAME ,
1589+ template_path = _TEST_TEMPLATE_PATH ,
1590+ job_id = _TEST_PIPELINE_JOB_ID ,
1591+ parameter_values = _TEST_PIPELINE_PARAMETER_VALUES ,
1592+ enable_caching = True ,
1593+ )
1594+
1595+ job .submit (
1596+ service_account = _TEST_SERVICE_ACCOUNT ,
1597+ network = _TEST_NETWORK ,
1598+ )
1599+
1600+ assert job .state == gca_pipeline_state .PipelineState .PIPELINE_STATE_RUNNING
1601+ assert job .state == gca_pipeline_state .PipelineState .PIPELINE_STATE_RUNNING
1602+ assert job .has_failed
1603+
1604+ @pytest .mark .parametrize (
1605+ "job_spec" ,
1606+ [_TEST_PIPELINE_SPEC_JSON , _TEST_PIPELINE_SPEC_YAML , _TEST_PIPELINE_JOB ],
1607+ )
1608+ def test_pipeline_job_has_failed_property_with_no_submit (
1609+ self , mock_load_yaml_and_json
1610+ ):
1611+ job = pipeline_jobs .PipelineJob (
1612+ display_name = _TEST_PIPELINE_JOB_DISPLAY_NAME ,
1613+ template_path = _TEST_TEMPLATE_PATH ,
1614+ job_id = _TEST_PIPELINE_JOB_ID ,
1615+ parameter_values = _TEST_PIPELINE_PARAMETER_VALUES ,
1616+ enable_caching = True ,
1617+ )
1618+
1619+ with pytest .raises (
1620+ RuntimeError ,
1621+ match = r"PipelineJob resource has not been created\." ,
1622+ ):
1623+ assert job .has_failed
1624+
15701625 @pytest .mark .parametrize (
15711626 "job_spec" ,
15721627 [_TEST_PIPELINE_SPEC_JSON , _TEST_PIPELINE_SPEC_YAML , _TEST_PIPELINE_JOB ],
0 commit comments