tests(langchain-sdk): Update conftest to be able to run tests in local#222
Closed
twishabansal wants to merge 4 commits into
Closed
tests(langchain-sdk): Update conftest to be able to run tests in local#222twishabansal wants to merge 4 commits into
twishabansal wants to merge 4 commits into
Conversation
anubhav756
approved these changes
Jan 17, 2025
kurtisvg
approved these changes
Jan 17, 2025
kurtisvg
requested changes
Jan 21, 2025
Comment on lines
+84
to
+101
| # Try getting the token using gcloud (for local development) | ||
| result = subprocess.run( | ||
| ["gcloud", "auth", "print-identity-token"], | ||
| capture_output=True, | ||
| text=True, | ||
| check=True, | ||
| ) | ||
| return result.stdout.strip() | ||
| except (subprocess.CalledProcessError, FileNotFoundError): | ||
| request = google.auth.transport.requests.Request() | ||
| credentials = compute_engine.IDTokenCredentials( | ||
| request=request, | ||
| target_audience=client_id, | ||
| use_metadata_identity_endpoint=True, | ||
| ) | ||
| if not credentials.valid: | ||
| credentials.refresh(request) | ||
| return credentials.token |
Collaborator
There was a problem hiding this comment.
I'm not sure I agree with this flow. I think ideally it should be trying the metadata server first, and falling back to gcloud if it's unable to reach. An alternative would be use an env var to signal which to use.
Ideally, we should not rely on "gcloud auth" as it's not semantically versioned (and I've personally been bit by it changing int the past)
Contributor
|
Migrated PR to googleapis/mcp-toolbox-sdk-python#18 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Getting an id token from metadata server does not work on local systems. This causes test failures for auth tests locally. This PR fixes the issue.
This unblocks https://b.corp.google.com/issues/385051620