googleapis / googleapis/python-aiplatform
[aiplatform] Allow explicit project_id parameter when initializing api_client
- 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ả
Hi,
I noticed an issue when initializing the API client in aiplatform.
In [base.py#L568](https://github.com/googleapis/python-aiplatform/blob/main/google/cloud/aiplatform/base.py#L568), the `api_client` is initialized with only the `credentials object`, but without an explicit `project_id`:
```
self.api_client = self._instantiate_client(
location=self.location,
credentials=self.credentials,
appended_user_agent=appended_user_agent,
)
```
The problem is that the credentials object only carries the `quota project ID` (see the [google.auth.credentials reference](https://google-auth.readthedocs.io/en/stable/reference/google.auth.credentials.html)), not the actual project ID.
This makes it impossible to specify a different project ID for API requests other than the one used for quota billing.
## Expected behavior
It should be possible to initialize the api_client with an explicit project_id, separate from the quota_project_id in the credentials.
## Why this matters
Some users may want to:
* Use credentials tied to one project for billing/quota purposes
* Target a different project for Vertex AI resources
Currently, this scenario is not supported because the project_id cannot be overridden.
## Possible solution
Support a project argument when creating the client and pass it explicitly:
```
self.api_client = self._instantiate_client(
location=self.location,
credentials=self.credentials,
appended_user_agent=appended_user_agent,
project=project_id, # <-- new
)
```
This would align with other Google Cloud client libraries that allow explicit project configuration.
Thanks!
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu trong google/cloud/aiplatform/base.py, tại phần khởi tạo api_client quanh dòng 568, và theo dõi _instantiate_client để xem các đối số của client được truyền như thế nào. Thêm hỗ trợ cho project_id tường minh, giữ nó tách biệt với ID dự án quota của thông tin xác thực, sau đó xác minh rằng các yêu cầu API có thể nhắm đến dự án được cấu hình tường minh.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- ai, api
- Loại issue
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 45/100