Skip to content

Commit a7ec902

Browse files
sararobcopybara-github
authored andcommitted
chore: Improve resource cleanup for Vertex SDK system tests
FUTURE_COPYBARA_INTEGRATE_REVIEW=#6299 from googleapis:release-please--branches--main 0855775 PiperOrigin-RevId: 865540270
1 parent 94b9149 commit a7ec902

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

.github/workflows/mypy.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ on:
88
pull_request:
99
branches:
1010
- main
11-
paths:
12-
- 'vertexai/_genai/**'
1311

1412
jobs:
1513
genai-mypy:

tests/system/aiplatform/e2e_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ def delete_staging_bucket(self, shared_state: Dict[str, Any]):
116116

117117
# Get the staging bucket used for testing and wipe it
118118
bucket = shared_state["bucket"]
119-
bucket.delete(force=True)
119+
bucket.delete_blobs(bucket.list_blobs())
120+
bucket.delete()
120121

121122
@pytest.fixture(scope="class")
122123
def prepare_bigquery_dataset(

tests/system/aiplatform/test_dataset.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import uuid
2020
import pytest
2121
import importlib
22+
import logging
2223

2324
import pandas as pd
2425
import re
@@ -162,7 +163,12 @@ def staging_bucket(self, storage_client):
162163

163164
yield bucket
164165

165-
bucket.delete(force=True)
166+
try:
167+
blobs = list(bucket.list_blobs())
168+
bucket.delete_blobs(blobs)
169+
bucket.delete()
170+
except Exception as e:
171+
logging.exception(f"Failed to cleanup bucket {new_staging_bucket}: {e}")
166172

167173
@pytest.fixture()
168174
def dataset_gapic_client(self):

tests/system/aiplatform/test_model_evaluation.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ def staging_bucket(self, storage_client):
8282

8383
yield bucket
8484

85+
try:
86+
blobs = list(bucket.list_blobs())
87+
bucket.delete_blobs(blobs)
88+
bucket.delete()
89+
except Exception as e:
90+
_LOGGER.info(f"Failed to delete bucket {new_staging_bucket}: {e}")
91+
8592
def test_model_evaluate_custom_tabular_model(self, staging_bucket, shared_state):
8693
credentials, _ = auth.default(
8794
scopes=["https://www.googleapis.com/auth/cloud-platform"]

tests/system/aiplatform/test_model_monitoring.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def test_mdm_two_models_one_valid_config(self, shared_state):
165165
location=e2e_base._LOCATION,
166166
endpoint=self.endpoint,
167167
)
168+
shared_state["resources"].append(job)
168169

169170
gapic_job = job._gca_resource
170171
assert (

0 commit comments

Comments
 (0)