Skip to content

Commit

Permalink
update sync usage in deleting child resources
Browse files Browse the repository at this point in the history
  • Loading branch information
morgandu committed Nov 30, 2021
1 parent e50e763 commit 8b75b2e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
10 changes: 5 additions & 5 deletions google/cloud/aiplatform/_featurestores/entity_type.py
Expand Up @@ -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.
Expand All @@ -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()
2 changes: 1 addition & 1 deletion google/cloud/aiplatform/_featurestores/feature.py
Expand Up @@ -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,
Expand Down
12 changes: 7 additions & 5 deletions google/cloud/aiplatform/_featurestores/featurestore.py
Expand Up @@ -293,17 +293,17 @@ 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,
)

@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:
Expand All @@ -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()
2 changes: 1 addition & 1 deletion tests/system/aiplatform/test_featurestore.py
Expand Up @@ -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):

Expand Down

0 comments on commit 8b75b2e

Please sign in to comment.