Skip to content

Commit

Permalink
feat: Release API key support for Predict
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 734290755
  • Loading branch information
vertex-sdk-bot authored and copybara-github committed Mar 8, 2025
1 parent 80cfc2f commit c4ce462
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion google/cloud/aiplatform/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,15 +699,19 @@ def __init__(

@property
def _prediction_client(self) -> utils.PredictionClientWithOverride:
api_key = initializer.global_config.api_key
if api_key and initializer.global_config.project:
api_key = None
# The attribute might not exist due to issues in
# `VertexAiResourceNounWithFutureManager._sync_object_with_future_result`
# We should switch to @functools.cached_property once its available.
if not getattr(self, "_prediction_client_value", None):
self._prediction_client_value = initializer.global_config.create_client(
client_class=utils.PredictionClientWithOverride,
credentials=self.credentials,
location_override=self.location,
location_override=self.location if not api_key else None,
prediction_client=True,
api_key=api_key,
)
return self._prediction_client_value

Expand Down

0 comments on commit c4ce462

Please sign in to comment.