@pytest.fixture(scope="class")
def tear_down_resources(self, shared_state: Dict[str, Any]):
"""Delete every Vertex AI resource created during test"""
yield
# TODO(b/218310362): Add resource deletion system tests
# Bring all Endpoints to the front of the list
# Ensures Models are undeployed first before we attempt deletion
shared_state["resources"].sort(
key=lambda r: 1
if isinstance(r, aiplatform.Endpoint)
or isinstance(r, aiplatform.MatchingEngineIndexEndpoint)
else 2
)
for resource in shared_state["resources"]:
try:
if isinstance(
resource,
(
aiplatform.Endpoint,
aiplatform.Featurestore,
aiplatform.MatchingEngineIndexEndpoint,
),
):
# For endpoint, undeploy model then delete endpoint
# For featurestore, force delete its entity_types and features with the featurestore
resource.delete(force=True)
elif isinstance(resource, aiplatform.Experiment):
resource.delete(delete_backing_tensorboard_runs=True)
else:
resource.delete()
except exceptions.GoogleAPIError as e:
logging.error(f"Could not delete resource: {resource} due to: {e}")
# When an Experiment has a backing_tensorboard, the Experiment needs to be deleted first
# This is used by the autologging tests
Note: #1466 was also for this test, but it was closed more than 10 days ago. So, I didn't mark it flaky.
commit: 2842389
buildURL: Build Status, Sponge
status: failed
Test output
self = shared_state = {'resources': [ reso...e: projects/580378083368/locations/us-central1/metadataStores/default/executions/3074333e-6457-4968-a1e2-8c9dc83c5155]}
E KeyError: 'tensorboard'
tests/system/aiplatform/e2e_base.py:207: KeyError