googleapis / googleapis/python-aiplatform

find_neighbors with REST transport fails unless project and location are set in aiplatform.init

未关闭
#5,467 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
api: vertex-ai
主要语言
Python
星标
905
派生
465
平均合并
1 天 13 小时
30 天内合并 PR
44

描述

`MatchingEngineIndexEndpoint.find_neighbors` fails when using `api_transport="rest"` if `project` and `location` are not explicitly passed to `aiplatform.init()`. The gRPC transport works correctly without these explicit parameters.

The REST call results in a `400 BadRequest` error: `Could not find field "%24alt" in the type "google.cloud.aiplatform.v1beta1.FindNeighborsRequest"`.

Is it intended that the REST transport requires explicit `project` and `location` in `init`, while gRPC can infer them from the endpoint's resource name? The behavior seems inconsistent.

**Code Example:**

```python
from google.cloud import aiplatform

# Fails with the below configuration
aiplatform.init(api_transport="rest")

# This configuration works
# aiplatform.init(api_transport="grpc")

# This configuration also works
# from google.cloud.aiplatform.initializer import initializer
# aiplatform.init(
# project=GCP.project,
# location=GCP.location,
# api_transport="rest"
# )

def get_docs_search_endpoint():
return aiplatform.MatchingEngineIndexEndpoint(Artifacts.docs_search_endpoint_id)

docs_search_endpoint = get_docs_search_endpoint()

try:
match_resp = docs_search_endpoint.find_neighbors(
deployed_index_id=Artifacts.docs_search_deployment_id,
queries=[[1] * 768],
num_neighbors=500,
)
print(match_resp)
except Exception as e:
print(e)

```

**Stack Trace:**

```
google.api_core.exceptions.BadRequest: 400 POST https://209XXXX46.us-central1-901XXXX18323.vdb.vertexai.goog/v1beta1/projects/901XXXX8323/locations/us-central1/indexEndpoints/793471XXXX752470528:findNeighbors?%24alt=json%3Benum-encoding%3Dint: Could not find field "%24alt" in the type "google.cloud.aiplatform.v1beta1.FindNeighborsRequest".
```

贡献指南

打开贡献指南

调研方向

从 MatchingEngineIndexEndpoint.find_neighbors 和 stack trace 中显示的 REST 请求开始。比较 aiplatform.init(api_transport="rest") 和 gRPC 传输在省略 project 和 location 时如何获取它们。完成标准是 REST 能够一致地推断这些值,或者预期要求已得到明确记录并由回归测试覆盖。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
api, machine-learning
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。