googleapis / googleapis/python-aiplatform
PrivateEndpoint.predict_async tries to access public endpoint
- Dominant language
- Python
- Stars
- 905
- Forks
- 465
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 44
Description
#### Environment details
- OS type and version: GCP VM
- Python version: 3.10.13
- pip version: 23.3.2
- `google-cloud-aiplatform` version: 1.40.0
#### Steps to reproduce
Create a `PrivateEndpoint` class and call `predict_async`
#### Code example
```python
endpoint = aiplatform.PrivateEndpoint(
endpoint_name=PRIVATE_ENDPOINT_ID,
project=PROJECT_ID,
location=REGION,
)
instance= {
"prompt": "Hi, Google."
}
instances = [instance]
prediction = endpoint.predict(instances=instances) # WORKS
prediction = await endpoint.predict_async(instances=instances) # DOESN'T WORK
```
#### Stack trace
```
---------------------------------------------------------------------------
AioRpcError Traceback (most recent call last)
File /opt/conda/lib/python3.10/site-packages/google/api_core/grpc_helpers_async.py:81, in _WrappedUnaryResponseMixin.__await__(self)
80 try:
---> 81 response = yield from self._call.__await__()
82 return response
File /opt/conda/lib/python3.10/site-packages/grpc/aio/_call.py:318, in _UnaryResponseMixin.__await__(self)
317 else:
--> 318 raise _create_rpc_error(
319 self._cython_call._initial_metadata,
320 self._cython_call._status,
321 )
322 else:
AioRpcError:
The above exception was the direct cause of the following exception:
FailedPrecondition Traceback (most recent call last)
Cell In[9], line 1
----> 1 prediction = await endpoint.predict_async(instances=instances)
2 prediction
File /opt/conda/lib/python3.10/site-packages/google/cloud/aiplatform/models.py:1636, in Endpoint.predict_async(self, instances, parameters, timeout)
1601 """Make an asynchronous prediction against this Endpoint.
1602 Example usage:
1603 ```
(...)
1632 Prediction with returned predictions and Model ID.
1633 """
1634 self.wait()
-> 1636 prediction_response = await self._prediction_async_client.predict(
1637 endpoint=self._gca_resource.name,
1638 instances=instances,
1639 parameters=parameters,
1640 timeout=timeout,
1641 )
1643 return Prediction(
1644 predictions=[
1645 json_format.MessageToDict(item)
(...)
1650 model_resource_name=prediction_response.model,
1651 )
File /opt/conda/lib/python3.10/site-packages/google/cloud/aiplatform_v1/services/prediction_service/async_client.py:360, in PredictionServiceAsyncClient.predict(self, request, endpoint, instances, parameters, retry, timeout, metadata)
355 metadata = tuple(metadata) + (
356 gapic_v1.routing_header.to_grpc_metadata((("endpoint", request.endpoint),)),
357 )
359 # Send the request.
--> 360 response = await rpc(
361 request,
362 retry=retry,
363 timeout=timeout,
364 metadata=metadata,
365 )
367 # Done; return the response.
368 return response
File /opt/conda/lib/python3.10/site-packages/google/api_core/grpc_helpers_async.py:84, in _WrappedUnaryResponseMixin.__await__(self)
82 return response
83 except grpc.RpcError as rpc_error:
---> 84 raise exceptions.from_grpc_error(rpc_error) from rpc_error
FailedPrecondition: 400 Making request from public OnePlatform API is not allowed on a private Endpoint peered with network (projects/PROJECT_ID/global/networks/default).
```
Contributor guide
Assessment
This issue has not been assessed yet.