Content-Length: 445124 | pFad | http://github.com/googleapis/python-aiplatform/commit/fc6d893b2191442d5e1edb9c097db56ef05fc5a5

8A fix: Fix dedicated endpoint DNS is empty · googleapis/python-aiplatform@fc6d893 · GitHub
Skip to content

Commit fc6d893

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
fix: Fix dedicated endpoint DNS is empty
PiperOrigin-RevId: 760826747
1 parent 905fdcd commit fc6d893

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

google/cloud/aiplatform/models.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,15 @@ def dedicated_endpoint_dns(self) -> Optional[str]:
791791
If dedicated endpoint is not enabled, this property returns None.
792792
"""
793793
if re.match(r"^projects/.*/endpoints/.*$", self._gca_resource.name):
794-
self._assert_gca_resource_is_available()
795-
return getattr(self._gca_resource, "dedicated_endpoint_dns", None)
794+
dedicated_endpoint_dns = getattr(
795+
self._gca_resource, "dedicated_endpoint_dns", None
796+
)
797+
if self.dedicated_endpoint_enabled and not dedicated_endpoint_dns:
798+
self._sync_gca_resource()
799+
dedicated_endpoint_dns = getattr(
800+
self._gca_resource, "dedicated_endpoint_dns", None
801+
)
802+
return dedicated_endpoint_dns
796803
return None
797804

798805
@property
@@ -2452,7 +2459,7 @@ def predict(
24522459
model_resource_name=prediction_response.model,
24532460
)
24542461

2455-
if self.dedicated_endpoint_dns is None:
2462+
if not self.dedicated_endpoint_dns:
24562463
raise ValueError(
24572464
"Dedicated endpoint DNS is empty. Please make sure endpoint"
24582465
"and model are ready before making a prediction."
@@ -2610,7 +2617,7 @@ def raw_predict(
26102617
)
26112618

26122619
if self.dedicated_endpoint_enabled:
2613-
if self.dedicated_endpoint_dns is None:
2620+
if not self.dedicated_endpoint_dns:
26142621
raise ValueError(
26152622
"Dedicated endpoint DNS is empty. Please make sure endpoint"
26162623
"and model are ready before making a prediction."
@@ -2682,7 +2689,7 @@ def stream_raw_predict(
26822689
)
26832690

26842691
if self.dedicated_endpoint_enabled:
2685-
if self.dedicated_endpoint_dns is None:
2692+
if not self.dedicated_endpoint_dns:
26862693
raise ValueError(
26872694
"Dedicated endpoint DNS is empty. Please make sure endpoint"
26882695
"and model are ready before making a prediction."

tests/unit/aiplatform/test_endpoints.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,20 @@ def get_dedicated_endpoint_mock():
364364
yield get_endpoint_mock
365365

366366

367+
@pytest.fixture
368+
def get_dedicated_endpoint_no_dns_mock():
369+
with mock.patch.object(
370+
endpoint_service_client.EndpointServiceClient, "get_endpoint"
371+
) as get_endpoint_mock:
372+
get_endpoint_mock.return_value = gca_endpoint.Endpoint(
373+
display_name=_TEST_DISPLAY_NAME,
374+
name=_TEST_ENDPOINT_NAME,
375+
encryption_spec=_TEST_ENCRYPTION_SPEC,
376+
dedicated_endpoint_enabled=True,
377+
)
378+
yield get_endpoint_mock
379+
380+
367381
@pytest.fixture
368382
def get_model_mock():
369383
with mock.patch.object(
@@ -2662,6 +2676,21 @@ def test_predict_dedicated_endpoint(self, predict_endpoint_http_mock):
26622676
timeout=None,
26632677
)
26642678

2679+
@pytest.mark.usefixtures("get_dedicated_endpoint_no_dns_mock")
2680+
def test_predict_dedicated_endpoint_without_dns(self, predict_endpoint_http_mock):
2681+
test_endpoint = models.Endpoint(_TEST_ENDPOINT_NAME)
2682+
2683+
with pytest.raises(ValueError) as err:
2684+
test_endpoint.predict(
2685+
instances=_TEST_INSTANCES,
2686+
parameters={"param": 3.0},
2687+
use_dedicated_endpoint=True,
2688+
)
2689+
assert err.match(
2690+
regexp=r"Dedicated endpoint DNS is empty. Please make sure endpoint"
2691+
"and model are ready before making a prediction."
2692+
)
2693+
26652694
@pytest.mark.usefixtures("get_dedicated_endpoint_mock")
26662695
def test_predict_dedicated_endpoint_with_timeout(self, predict_endpoint_http_mock):
26672696
test_endpoint = models.Endpoint(_TEST_ENDPOINT_NAME)

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/googleapis/python-aiplatform/commit/fc6d893b2191442d5e1edb9c097db56ef05fc5a5

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy