googleapis / langchain-google-alloydb-pg-python

Apache License 2.0
13 stars 9 forks source link

refactor: return early if credentials have service account field #117

Closed jackwotherspoon closed 5 months ago

jackwotherspoon commented 5 months ago

As pointed out in #110 there is no point of calling the Google OAuth2 endpoint if we already have the service account field tied to the credentials... unless I'm missing something.

https://github.com/googleapis/langchain-google-alloydb-pg-python/blob/9ce7a4bc4257d7e0fe90c1bab1740326b4c7d12f/src/langchain_google_alloydb_pg/alloydb_engine.py#L62-L75

We should be returning early and skipping the overhead of the API call if we already know the IAM principal based on the credentials attribute. This is what we do already in the Cloud SQL MySQL package.