File tree 2 files changed +18
-6
lines changed
aiplatform_v1/services/prediction_service
2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -699,15 +699,19 @@ def __init__(
699
699
700
700
@property
701
701
def _prediction_client (self ) -> utils .PredictionClientWithOverride :
702
+ api_key = initializer .global_config .api_key
703
+ if api_key and initializer .global_config .project :
704
+ api_key = None
702
705
# The attribute might not exist due to issues in
703
706
# `VertexAiResourceNounWithFutureManager._sync_object_with_future_result`
704
707
# We should switch to @functools.cached_property once its available.
705
708
if not getattr (self , "_prediction_client_value" , None ):
706
709
self ._prediction_client_value = initializer .global_config .create_client (
707
710
client_class = utils .PredictionClientWithOverride ,
708
711
credentials = self .credentials ,
709
- location_override = self .location ,
712
+ location_override = self .location if not api_key else None ,
710
713
prediction_client = True ,
714
+ api_key = api_key ,
711
715
)
712
716
return self ._prediction_client_value
713
717
Original file line number Diff line number Diff line change @@ -249,11 +249,19 @@ def endpoint_path(
249
249
endpoint : str ,
250
250
) -> str :
251
251
"""Returns a fully-qualified endpoint string."""
252
- return "projects/{project}/locations/{location}/endpoints/{endpoint}" .format (
253
- project = project ,
254
- location = location ,
255
- endpoint = endpoint ,
256
- )
252
+ if project == "None" :
253
+ return "endpoints/{endpoint}" .format (
254
+ endpoint = endpoint ,
255
+ )
256
+ else :
257
+ return (
258
+ "projects/{project}/locations/{location}/endpoints/{endpoint}"
259
+ .format (
260
+ project = project ,
261
+ location = location ,
262
+ endpoint = endpoint ,
263
+ )
264
+ )
257
265
258
266
@staticmethod
259
267
def parse_endpoint_path (path : str ) -> Dict [str , str ]:
You can’t perform that action at this time.
0 commit comments