From d25905eb115e981486b2c175768b03def4fd0a4b Mon Sep 17 00:00:00 2001 From: Yi Hu Date: Thu, 19 Oct 2023 09:57:05 -0400 Subject: [PATCH] Fix Python PreCommit GHA recommendations_ai teardown (#29067) --- .../apache_beam/ml/gcp/recommendations_ai_test_it.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sdks/python/apache_beam/ml/gcp/recommendations_ai_test_it.py b/sdks/python/apache_beam/ml/gcp/recommendations_ai_test_it.py index 0ae68a298421..9f739de7883d 100644 --- a/sdks/python/apache_beam/ml/gcp/recommendations_ai_test_it.py +++ b/sdks/python/apache_beam/ml/gcp/recommendations_ai_test_it.py @@ -70,9 +70,12 @@ def extract_prediction(response): recommendationengine is None, "Recommendations AI dependencies not installed.") class RecommendationAIIT(unittest.TestCase): + test_ran = False + def test_create_catalog_item(self): with TestPipeline(is_integration_test=True) as p: + RecommendationAIIT.test_ran = True output = ( p | 'Create data' >> beam.Create([CATALOG_ITEM]) | 'Create CatalogItem' >> @@ -85,6 +88,7 @@ def test_create_user_event(self): USER_EVENT = {"event_type": "page-visit", "user_info": {"visitor_id": "1"}} with TestPipeline(is_integration_test=True) as p: + RecommendationAIIT.test_ran = True output = ( p | 'Create data' >> beam.Create([USER_EVENT]) | 'Create UserEvent' >> recommendations_ai.WriteUserEvent(project=GCP_TEST_PROJECT) @@ -96,6 +100,7 @@ def test_predict(self): USER_EVENT = {"event_type": "page-visit", "user_info": {"visitor_id": "1"}} with TestPipeline(is_integration_test=True) as p: + RecommendationAIIT.test_ran = True output = ( p | 'Create data' >> beam.Create([USER_EVENT]) | 'Predict UserEvent' >> recommendations_ai.PredictUserEvent( @@ -106,6 +111,9 @@ def test_predict(self): @classmethod def tearDownClass(cls): + if not cls.test_ran: + raise unittest.SkipTest('all test skipped') + client = recommendationengine.CatalogServiceClient() parent = ( f'projects/{GCP_TEST_PROJECT}/locations/'