fix: Set prediction client when listing Endpoints#512
Conversation
sasha-gitg
left a comment
There was a problem hiding this comment.
This PR should also include a test to confirm the fix. Thanks!
google/cloud/aiplatform/models.py
Outdated
|
|
||
| endpoint._gca_resource = gapic_resource | ||
| endpoint._prediction_client = self._instantiate_prediction_client( | ||
| location=location or initializer.global_config.location, |
There was a problem hiding this comment.
Just realized there is a bug here and in the implementation it's based on:
If passed a full resource name that doesn't match location or init.location then will instantiate the client in the incorrect location.
Please change this here and in the reference above to the use the constructed endpoint resource's location.
There was a problem hiding this comment.
Added calls to _get_and_validate_project_location() in both Endpoint.__init__() and Endpoint._construct_sdk_resource_from_gapic() to allow the full resource name to override location.
There was a problem hiding this comment.
Actually I realized that downstream calls in VertexAiResourceNounWithFutureManager._empty_constructor() and VertexAiResourceNounWithFutureManager.__init__() already call _get_and_validate_project_location().
I've updated the call to _instantiate_prediction_client() to use the location set by those methods instead of the location argument.
sasha-gitg
left a comment
There was a problem hiding this comment.
This is great. Thanks, Vinny!
* fix: Set prediction client when listing Endpoints * Address reviewer comments * Remove redundant init() in TestEndpoints * Update location passed to _instantiate_prediction_client()
Overrides
VertexAiResourceNounWithFutureManager._construct_sdk_resource_from_gapicwithEndpoint._construct_sdk_resource_from_gapic.Subclass method initializes the Prediction service client, allowing users to call
predict()/explain()on anEndpointreturned by a call tolist()Fixes b/192002630 🦕