-
Notifications
You must be signed in to change notification settings - Fork 22
Add vertex ai support #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| try: | ||
| credentials = service_account.Credentials.from_service_account_info(self.cred_json, scopes=["https://www.googleapis.com/auth/cloud-platform"]) | ||
|
|
||
| # refresh token - run in thread pool to avoid blocking |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im wondering if we could optimize this logic. OAuth2 Token's generally last an hour, but we are refreshing the token every call. Instead could we store the token in Redis cache, and then check for cache miss/expiry and then refresh the token.
Implementation approach:
- Check Redis cache for existing valid token first
- If cache miss or expired, refresh token and cache it
- Use credentials.expiry to set proper TTL (with 5-10 min safety buffer)
- Cache key: f"vertex_token:{hash(service_account_json)}"
Could slightly help performance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion 👍. I have some questions regarding to it. Let's move the discussion to your PR: #15
No description provided.