From 8b75b2e1e1a7a628553876c78df2856318404ef2 Mon Sep 17 00:00:00 2001 From: Morgan Du Date: Tue, 30 Nov 2021 10:59:36 -0800 Subject: [PATCH] update sync usage in deleting child resources --- .../cloud/aiplatform/_featurestores/entity_type.py | 10 +++++----- google/cloud/aiplatform/_featurestores/feature.py | 2 +- .../cloud/aiplatform/_featurestores/featurestore.py | 12 +++++++----- tests/system/aiplatform/test_featurestore.py | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/google/cloud/aiplatform/_featurestores/entity_type.py b/google/cloud/aiplatform/_featurestores/entity_type.py index 59923b6b2c..3155fd2113 100644 --- a/google/cloud/aiplatform/_featurestores/entity_type.py +++ b/google/cloud/aiplatform/_featurestores/entity_type.py @@ -361,9 +361,7 @@ def list_features( ) @base.optional_sync() - def delete_features( - self, feature_ids: List[str], sync: Optional[bool] = True, - ) -> None: + def delete_features(self, feature_ids: List[str], sync: bool = True,) -> None: """Deletes feature resources in this EntityType given their feature IDs. WARNING: This deletion is permanent. @@ -375,9 +373,11 @@ def delete_features( will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed. """ + features = [] for feature_id in feature_ids: feature = self.get_feature(feature_id=feature_id) - feature.delete(sync=sync) + feature.delete(sync=False) + features.append(feature) - if not sync: + for feature in features: feature.wait() diff --git a/google/cloud/aiplatform/_featurestores/feature.py b/google/cloud/aiplatform/_featurestores/feature.py index ee9ce6fe9e..2f56d1813a 100644 --- a/google/cloud/aiplatform/_featurestores/feature.py +++ b/google/cloud/aiplatform/_featurestores/feature.py @@ -317,7 +317,7 @@ def list( location=location, credentials=credentials, parent=utils.full_resource_name( - resource_name=entity_type_id, + resource_name=entity_type_name, resource_noun=f"featurestores/{featurestore_id}/entityTypes", project=project, location=location, diff --git a/google/cloud/aiplatform/_featurestores/featurestore.py b/google/cloud/aiplatform/_featurestores/featurestore.py index bc7278d887..b9b0612881 100644 --- a/google/cloud/aiplatform/_featurestores/featurestore.py +++ b/google/cloud/aiplatform/_featurestores/featurestore.py @@ -293,7 +293,7 @@ def list_entity_types( - ``update_time`` Returns: - List[EntityTypes] - A list of managed entityType resource objects. + List[featurestores.EntityType] - A list of managed entityType resource objects. """ return _featurestores.EntityType.list( featurestore_name=self.resource_name, filter=filter, order_by=order_by, @@ -301,9 +301,9 @@ def list_entity_types( @base.optional_sync() def delete_entity_types( - self, entity_type_ids: List[str], sync: Optional[bool] = True, + self, entity_type_ids: List[str], sync: bool = True, ) -> None: - """Deletes entity_type resources in this Featurestre given their entity_type IDs. + """Deletes entity_type resources in this Featurestore given their entity_type IDs. WARNING: This deletion is permanent. Args: @@ -314,9 +314,11 @@ def delete_entity_types( will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed. """ + entity_types = [] for entity_type_id in entity_type_ids: entity_type = self.get_entity_type(entity_type_id=entity_type_id) - entity_type.delete(sync=sync) + entity_type.delete(sync=False) + entity_types.append(entity_type) - if not sync: + for entity_type in entity_types: entity_type.wait() diff --git a/tests/system/aiplatform/test_featurestore.py b/tests/system/aiplatform/test_featurestore.py index daca976045..324274aa06 100644 --- a/tests/system/aiplatform/test_featurestore.py +++ b/tests/system/aiplatform/test_featurestore.py @@ -22,7 +22,7 @@ class TestFeaturestore(e2e_base.TestEndToEnd): - _temp_prefix = "temp-vertex-sdk-e2e-test" + _temp_prefix = "temp-vertex-sdk-e2e-feature-store-test" def test_create_and_get_featurestore(self, shared_state):