feat: gapic centralization into api core#17628
Open
hebaalazzeh wants to merge 20 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a new client_helpers module in google-api-core containing helper functions for GAPIC client initialization, and adds global lazy imports control (__lazy_modules__) to google-cloud-compute. The review feedback suggests optimizing performance by compiling the mTLS endpoint regular expression at the module level rather than inside the function. Additionally, it recommends correcting the type annotations in get_api_endpoint to use Optional[Any] for client_cert_source and Optional[str] for the return type.
…rs.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
5e1eb20 to
ad1c01f
Compare
Contributor
Author
|
/gemini |
…al client_helpers methods
c27695d to
2353e82
Compare
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.
Update and Release google-api-core
This PR introduces centralized helper functions into
google.api_core.gapic_v1.client_helpers. The goal of this centralization is to reduce package size, improve maintainability, and boost import performance of generated GAPIC clients by moving redundant, service-agnostic boilerplate logic intogoogle-api-core.Key Changes
google.api_core.gapic_v1.client_helperscontaining logic previously repeated across generated clients (e.g.,get_default_mtls_endpoint,use_client_cert_effective,get_api_endpoint, andget_universe_domain)._prefix from these functions so they can be securely imported and utilized by external generated clients._use_client_cert_effective = use_client_cert_effective) to prevent breaking changes for existing GAPIC clients (over 2,400+ repos) that have not yet been regenerated.test_client_helpers.py.grpcoptional dependencies gracefully to ensure tests pass ininstall_grpc=Falseenvironments.google-auth(e.g.<=2.14.1) pass in the CI test matrix by safely validatingshould_use_client_certavailability.Next Steps (Phase 2)
Once this PR is merged and a new minor version of
google-api-core(e.g.2.18.0) is released, we can update the GAPIC generator to utilize these centralized helpers and stop emitting the redundant logic.Note
Full details and baseline metrics are available in the attached Design Document.