googleapis / googleapis/python-aiplatform
[aiplatform] Allow explicit project_id parameter when initializing api_client
- Dominant language
- Python
- Stars
- 905
- Forks
- 465
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 44
Description
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!
Contributor guide
Research direction
Start in google/cloud/aiplatform/base.py at the api_client initialization around line 568 and trace _instantiate_client to see how client arguments are propagated. Add support for an explicit project_id while keeping it separate from the credentials' quota project ID, then verify that API requests can target the explicitly configured project.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai, api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100