@@ -210,6 +210,7 @@ def __init__(
210
210
will be used.
211
211
"""
212
212
213
+ print ("project: " + project or "None" + " location: " + location or "None" )
213
214
super ().__init__ (
214
215
project = project ,
215
216
location = location ,
@@ -662,7 +663,9 @@ def __init__(
662
663
endpoint_name (str):
663
664
Required. A fully-qualified endpoint resource name or endpoint ID.
664
665
Example: "projects/123/locations/us-central1/endpoints/456" or
665
- "456" when project and location are initialized or passed.
666
+ "456" when project and location are initialized or passed. If
667
+ project and location are not passed, the endpoint_name is assumed
668
+ to be fully-qualified.
666
669
project (str):
667
670
Optional. Project to retrieve endpoint from. If not set, project
668
671
set in aiplatform.init will be used.
@@ -681,14 +684,15 @@ def __init__(
681
684
resource_name = endpoint_name ,
682
685
)
683
686
684
- endpoint_name = utils .full_resource_name (
685
- resource_name = endpoint_name ,
686
- resource_noun = "endpoints" ,
687
- parse_resource_name_method = self ._parse_resource_name ,
688
- format_resource_name_method = self ._format_resource_name ,
689
- project = project ,
690
- location = location ,
691
- )
687
+ if project or initializer .global_config .project :
688
+ endpoint_name = utils .full_resource_name (
689
+ resource_name = endpoint_name ,
690
+ resource_noun = "endpoints" ,
691
+ parse_resource_name_method = self ._parse_resource_name ,
692
+ format_resource_name_method = self ._format_resource_name ,
693
+ project = project ,
694
+ location = location ,
695
+ )
692
696
693
697
# Lazy load the Endpoint gca_resource until needed
694
698
self ._gca_resource = gca_endpoint_compat .Endpoint (name = endpoint_name )
@@ -699,15 +703,19 @@ def __init__(
699
703
700
704
@property
701
705
def _prediction_client (self ) -> utils .PredictionClientWithOverride :
706
+ api_key = initializer .global_config .api_key
707
+ if api_key and initializer .global_config .project :
708
+ api_key = None
702
709
# The attribute might not exist due to issues in
703
710
# `VertexAiResourceNounWithFutureManager._sync_object_with_future_result`
704
711
# We should switch to @functools.cached_property once its available.
705
712
if not getattr (self , "_prediction_client_value" , None ):
706
713
self ._prediction_client_value = initializer .global_config .create_client (
707
714
client_class = utils .PredictionClientWithOverride ,
708
715
credentials = self .credentials ,
709
- location_override = self .location ,
716
+ location_override = self .location if not api_key else None ,
710
717
prediction_client = True ,
718
+ api_key = api_key ,
711
719
)
712
720
return self ._prediction_client_value
713
721
0 commit comments