Skip to content

Commit 243572c

Browse files
yinghsienwucopybara-github
authored andcommitted
feat: "global" endpoint supports "grpc" transport
PiperOrigin-RevId: 878650722
1 parent 7410b1d commit 243572c

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

google/cloud/aiplatform/initializer.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,6 @@ def init(
245245
# Set api_transport as "rest" if location is "global".
246246
if location == "global" and not api_transport:
247247
self._api_transport = "rest"
248-
elif location == "global" and api_transport == "grpc":
249-
raise ValueError(
250-
"api_transport cannot be 'grpc' when location is 'global'."
251-
)
252248
if experiment_description and experiment is None:
253249
raise ValueError(
254250
"Experiment needs to be set in `init` in order to add experiment"

tests/unit/aiplatform/test_initializer.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,16 @@ def test_create_client_with_global_location(self):
306306
assert client._transport._host == f"https://{constants.API_BASE_PATH}"
307307

308308
def test_create_client_with_global_location_and_grpc_transport(self):
309-
with pytest.raises(ValueError):
310-
initializer.global_config.init(
311-
project=_TEST_PROJECT, location="global", api_transport="grpc"
312-
)
309+
initializer.global_config.init(
310+
project=_TEST_PROJECT, location="global", api_transport="grpc"
311+
)
312+
client = initializer.global_config.create_client(
313+
client_class=utils.PredictionClientWithOverride
314+
)
315+
assert initializer.global_config.location == "global"
316+
assert initializer.global_config._api_transport == "grpc"
317+
assert isinstance(client, utils.PredictionClientWithOverride)
318+
assert client._transport._host == f"{constants.API_BASE_PATH}:443"
313319

314320
def test_create_client_with_api_key_and_grpc_transport(self):
315321
with pytest.raises(ValueError):

0 commit comments

Comments
 (0)