feat: delegate boilerplate helpers to google-api-core#17699
feat: delegate boilerplate helpers to google-api-core#17699hebaalazzeh wants to merge 15 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request centralizes several GAPIC helper functions (for routing, client certificates, environment configuration, and request ID setup) from the gapic-generator templates into google-api-core under google.api_core.gapic_v1. This refactoring simplifies the generated client code and consolidates the logic. The review feedback highlights two main areas for improvement: removing an unused import uuid statement in the client template, and preventing a potential AttributeError in get_api_endpoint when default_endpoint_template is None.
4c7310b to
7c06a55
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request contains two main sets of changes. First, in bigframes, it refactors iloc indexing on DataFrames and Series to defer ordering checks until necessary (avoiding them for no-op slices) and adds support for positional column indexing and assignment by offsets, which helps handle duplicate or non-string column names. Second, in gapic-generator and google-api-core, it centralizes common client helper functions (such as mTLS endpoint resolution, client certificate handling, universe domain validation, and request ID setup) into shared internal modules in google-api-core, removing duplicate code from the generator templates and generated tests. Regarding the feedback, a performance concern was raised in bigframes where calling key.to_pandas() on a boolean indexer downloads the entire Series or Index to the client, and a server-side implementation was suggested instead.
| key_list = ( | ||
| list(key) | ||
| if not isinstance(key, (bigframes.series.Series, indexes.Index)) | ||
| else list(key.to_pandas()) | ||
| ) |
There was a problem hiding this comment.
Using key.to_pandas() here will download the entire boolean Series or Index to the client. For large datasets, this can lead to significant performance degradation and high memory usage on the client side.
Consider implementing this logic on the server side. For a boolean bigframes.Series, you could use SQL window functions to generate row numbers, filter for True values, and then use the resulting row numbers for positional filtering. This would avoid a potentially large data transfer.
a5ea0fa to
9c48260
Compare
…verrides in generator testing noxfiles
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request centralizes client routing, certificate handling, and environment variable reading in the generated Python clients by delegating to helper modules in google.api_core.gapic_v1, allowing for the removal of redundant boilerplate code and unit tests. The review feedback highlights several key issues: first, avoid including test_utils* as a top-level package in setup.py to prevent namespace conflicts; second, avoid downgrading google-api-core and removing its hashes in requirements.txt; third, remove the hardcoded public PyPI index URL in WORKSPACE to support private mirrors; and finally, guard the local installation of ../google-api-core in noxfile.py with an existence check to ensure standalone testing remains functional.
| google-api-core==2.30.3 \ | ||
| --hash=sha256:a85761ba72c444dad5d611c2220633480b2b6be2521eca69cca2dbb3ffd6bfe8 \ | ||
| --hash=sha256:e601a37f148585319b26db36e219df68c5d07b6382cff2d580e83404e44d641b | ||
| google-api-core==2.25.0 |
There was a problem hiding this comment.
Downgrading google-api-core to 2.25.0 and removing its hashes in requirements.txt reduces security (by not verifying package integrity via hashes) and limits testing of the generator against newer versions of google-api-core (such as 2.30.3).
If this was done temporarily for testing the centralization changes, please ensure that requirements.txt is re-compiled using pip-compile to include the latest compatible version and its corresponding hashes before merging.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…oogle-api-core and hashes
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the Python GAPIC generator to delegate several client-side helper methods (such as mTLS endpoint routing, client certificate sourcing, environment variable configuration, and request ID setup) to the google.api_core.gapic_v1 library. Consequently, local implementations and their corresponding unit tests have been removed from the templates. The PR also updates the generator's dependencies, setup configuration, and test environments to support Python 3.11 and use the local version of google-api-core during monorepo testing. The reviewer noted that the regenerated golden files are out of sync with the updated unit test template (test_%service.py.j2), as they are missing the mock for CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE in the mock_mtls_env fixture. All golden files should be regenerated to ensure consistency.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the Python GAPIC generator templates to delegate routing, client certificate handling, environment configuration, and request ID setup to helper modules in google-api-core. It also cleans up redundant unit tests in the generated code and updates noxfile.py configurations to support local monorepo development. The review feedback highlights a mismatch between the template changes and the generated golden files regarding mocked environment variables, and recommends guarding several local google-api-core installations in noxfile.py with existence checks to prevent failures in sparse checkout environments.
…update goldens and ads-templates
… to regular to fix mypy import-untyped
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…h in Bazel WORKSPACE
Description
This draft PR updates the GAPIC generator templates to delegate common, service-agnostic boilerplate logic to the newly centralized functions in
google-api-core.gapic_v1.Related PR: #17628
Key Changes:
client.pyhave been updated so that boilerplate helper methods (such as_use_client_cert_effective,_get_api_endpoint, and_get_default_mtls_endpoint) now delegate their implementations to the centralizedapi-corefunctions (e.g.,_client_cert.use_client_cert_effective())._-prefixed methods from the generated clients entirely, we retain their definitions and signatures but delegate their logic. This ensures 100% backward compatibility for any existing code that might be monkey-patching or relying on these internal client methods.google-api-coredependency insetup.pyhas been temporarily pinned to thefeat/gapic-centralization-api-corebranch.Purpose of this Draft PR:
Running the showcase and unit tests against this draft PR will provide end-to-end integration verification that the
google-api-corecentralization branch works perfectly with generated code before we officially merge it.