Skip to content

Commit

Permalink
Fix Python PreCommit GHA recommendations_ai teardown (#29067)
Browse files Browse the repository at this point in the history
  • Loading branch information
Abacn authored Oct 19, 2023
1 parent f0e0c2f commit d25905e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sdks/python/apache_beam/ml/gcp/recommendations_ai_test_it.py
Original file line number Diff line number Diff line change
Expand Up @@ -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' >>
Expand All @@ -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)
Expand All @@ -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(
Expand All @@ -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/'
Expand Down

0 comments on commit d25905e

Please sign in to comment.