Skip to content

Commit c7526a1

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
fix: PrivateEndpoint predict method should set parameters in request payload.
PiperOrigin-RevId: 729160042
1 parent 7121770 commit c7526a1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

google/cloud/aiplatform/models.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3614,7 +3614,7 @@ def predict(
36143614
Example usage:
36153615
PSA based private endpoint:
36163616
3617-
response = my_private_endpoint.predict(instances=[...])
3617+
response = my_private_endpoint.predict(instances=[...], parameters={...})
36183618
my_predictions = response.predictions
36193619
36203620
PSC based private endpoint:
@@ -3680,7 +3680,7 @@ def predict(
36803680
response = self._http_request(
36813681
method="POST",
36823682
url=self.predict_http_uri,
3683-
body=json.dumps({"instances": instances}),
3683+
body=json.dumps({"instances": instances, "parameters": parameters}),
36843684
headers={"Content-Type": "application/json"},
36853685
)
36863686
prediction_response = json.loads(response.data)
@@ -3717,7 +3717,7 @@ def predict(
37173717
response = self._http_request(
37183718
method="POST",
37193719
url=url,
3720-
body=json.dumps({"instances": instances}),
3720+
body=json.dumps({"instances": instances, "parameters": parameters}),
37213721
headers=headers,
37223722
)
37233723

tests/unit/aiplatform/test_endpoints.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3525,7 +3525,7 @@ def test_psa_predict(self, predict_private_endpoint_mock):
35253525
predict_private_endpoint_mock.assert_called_once_with(
35263526
method="POST",
35273527
url="",
3528-
body='{"instances": [[1.0, 2.0, 3.0], [1.0, 3.0, 4.0]]}',
3528+
body='{"instances": [[1.0, 2.0, 3.0], [1.0, 3.0, 4.0]], "parameters": {"param": 3.0}}',
35293529
headers={"Content-Type": "application/json"},
35303530
)
35313531

@@ -3552,7 +3552,7 @@ def test_psc_predict(self, predict_private_endpoint_mock):
35523552
predict_private_endpoint_mock.assert_called_once_with(
35533553
method="POST",
35543554
url=f"https://{_TEST_ENDPOINT_OVERRIDE}/v1/projects/{_TEST_PROJECT}/locations/{_TEST_LOCATION}/endpoints/{_TEST_ID}:predict",
3555-
body='{"instances": [[1.0, 2.0, 3.0], [1.0, 3.0, 4.0]]}',
3555+
body='{"instances": [[1.0, 2.0, 3.0], [1.0, 3.0, 4.0]], "parameters": {"param": 3.0}}',
35563556
headers={
35573557
"Content-Type": "application/json",
35583558
"Authorization": "Bearer None",

0 commit comments

Comments
 (0)