feat: gapic centralization into api core#17628
Conversation
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
|
/gemini |
…al client_helpers methods
c27695d to
2353e82
Compare
1d7b5c2 to
3f02e35
Compare
|
Could we open a draft PR for gapic-generator with the template updates, temporarily pointing its test google-api-core dependency to this git branch? Running the gapic-generator-python CI (showcase and unit tests) on that draft PR will give us end-to-end verification that this branch integrates cleanly with generated code before we merge. |
…and enable REST tests without grpc
|
Converting to draft as it appears there are unrelated changes to |
…re_deps_from_source in noxfile
cb95824 to
a1341f0
Compare
Update and Release google-api-core
This PR introduces centralized helper functions into
google.api_core.gapic_v1. 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:_routing.py(get_default_mtls_endpoint,get_api_endpoint,get_universe_domain)_client_cert.py(use_client_cert_effective,get_client_cert_source)_config_helpers.py(read_environment_variables)_method_helpers.py(setup_request_id)_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_routing.py,test_client_cert.py,test_config_helpers.py,test_method_helpers.py).install_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.