chore(generator): delegate request-id setup to public request#17739
chore(generator): delegate request-id setup to public request#17739hebaalazzeh wants to merge 51 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the request ID setup logic in the generated client templates by delegating it to google.api_core.gapic_v1.method_helpers.setup_request_id instead of maintaining an inline implementation. As a result, the redundant unit tests for _setup_request_id have been removed from both the templates and the golden integration tests. There are no review comments, so I have no feedback to provide.
f037044 to
f25d768
Compare
a0bff77 to
613b392
Compare
f25d768 to
71b2f4e
Compare
e02ee4b to
db040bb
Compare
71b2f4e to
a8cc8d8
Compare
|
This implementation makes sense if we plan to bump up the api_core requirement Before merging, we need to:
There's also a chance we will want to keep a fallback implementation to keep supporting old api_core versions |
…lic helpers Introduces method_helpers module containing setup_request_id helper. Exposes the module as public in gapic_v1.
…t and improve docstring
90602cc to
76ac456
Compare
…lic helpers Introduces method_helpers module containing setup_request_id helper. Exposes the module as public in gapic_v1.
Updates generator templates and goldens to import public method_helpers from google-api-core gapic_v1 and call setup_request_id helper. Removes duplicate setup_request_id test logic from generated client unit tests.
…t and improve docstring
8e31d83 to
20adea6
Compare
20e4bea to
a8105ff
Compare
…_core requests.py
4659080 to
e243bbd
Compare
cd6b66e to
e052b61
Compare
57a8810 to
6f07478
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new compatibility module template _compat.py.j2 to provide fallbacks for older versions of google-api-core, and refactors the generator, client templates, and tests to use it. The review feedback highlights three main issues: a missing test__compat.py.j2 template for the newly added golden test file, an optimization opportunity in _compat.py.j2 to check if request is None before generating a UUID, and a mismatch between the template and the generated golden file where a less precise check in the golden file could incorrectly overwrite valid falsy values.
| {% if method_settings and method_settings.auto_populated_fields %} | ||
| {% set has_auto_populated_fields.value = true %} | ||
| {% endif %} | ||
| {% endfor %} |
There was a problem hiding this comment.
I think I commented this on a different PR, but can you clarify what has_auto_populated_fields is doing? Both for me, and as a comment for future maintainers
| "grpcio-tools", | ||
| ) | ||
| session.install("-e", ".") | ||
| session.install("-e", "../google-api-core") |
There was a problem hiding this comment.
This is probably fine, but is this required? Shouldn't the tests pass against the released api_core too?
Note that it will still use a pinned version on 3.10 (in line below this)
…ion and clean up allowed private templates
…s in client templates
…apper and remove Jinja namespace loops
…-api-core') from noxfile.py
…reach 100% statement and branch coverage
| get_universe_domain, | ||
| ) | ||
| except ImportError: | ||
| # TODO(https://github.com/googleapis/google-cloud-python/issues/17813): Remove these fallbacks when google-api-core >= 2.18.0 is the minimum required version. |
There was a problem hiding this comment.
The current api-core version is 2.33.0, so I assume these versions are incorrect?
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| """A compatibility module for older versions of google-api-core.""" |
There was a problem hiding this comment.
Is there a reason we're not seeing this file generated for all goldens?
| extras = "[async_rest]" | ||
|
|
||
| session.install("-e", f"{tmp_dir}{extras}", "-r", constraints_path) | ||
| session.install("-e", f"{tmp_dir}{extras}", "--no-build-isolation", "-r", constraints_path) |
There was a problem hiding this comment.
why was --no-build-isolation included?
Updates generator templates and goldens to import public
requestsfromgoogle-api-coregapic_v1and callsetup_request_idhelper. Removes duplicatesetup_request_idtest logic from generated client unit tests.Temporarily pointing to this PR then will revert once it is merged/released: