Skip to content

Commit

Permalink
fix: add self.wait() in operations after optional_sync supported reso…
Browse files Browse the repository at this point in the history
…urce creation (#1083)

Co-authored-by: Anthonios Partheniou <[email protected]>
  • Loading branch information
morgandu and parthea authored Mar 16, 2022
1 parent b7a5177 commit 79aeec1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@ def deploy_index(
MatchingEngineIndexEndpoint - IndexEndpoint resource object
"""

self.wait()

_LOGGER.log_action_start_against_resource(
"Deploying index", "index_endpoint", self,
)
Expand Down Expand Up @@ -591,6 +593,8 @@ def undeploy_index(
MatchingEngineIndexEndpoint - IndexEndpoint resource object
"""

self.wait()

_LOGGER.log_action_start_against_resource(
"Undeploying index", "index_endpoint", self,
)
Expand Down Expand Up @@ -652,6 +656,8 @@ def mutate_deployed_index(
Optional. Strings which should be sent along with the request as metadata.
"""

self.wait()

_LOGGER.log_action_start_against_resource(
"Mutating index", "index_endpoint", self,
)
Expand Down Expand Up @@ -691,6 +697,7 @@ def deployed_indexes(
Returns:
List[gca_matching_engine_index_endpoint.DeployedIndex] - Deployed indexes
"""
self._assert_gca_resource_is_available()
return self._gca_resource.deployed_indexes

@base.optional_sync()
Expand Down
4 changes: 4 additions & 0 deletions google/cloud/aiplatform/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,8 @@ def update(
ValueError: If `labels` is not the correct format.
"""

self.wait()

current_model_proto = self.gca_resource
copied_model_proto = current_model_proto.__class__(current_model_proto)

Expand Down Expand Up @@ -2496,6 +2498,8 @@ def export_model(
ValueError: If invalid arguments or export formats are provided.
"""

self.wait()

# Model does not support exporting
if not self.supported_export_formats:
raise ValueError(f"The model `{self.resource_name}` is not exportable.")
Expand Down

0 comments on commit 79aeec1

Please sign in to comment.