googleapis / googleapis/python-aiplatform

PrivateEndpoint.predict_async tries to access public endpoint

Đang mở
#3,307 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
api: vertex-ai
Ngôn ngữ chính
Python
Star
905
Fork
465
Merge trung bình
1 ngày 13 giờ
Pull request đã merge (30 ngày)
44

Mô tả

#### 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).
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.