chore(generator): delegate request-id setup to public request#17739
chore(generator): delegate request-id setup to public request#17739hebaalazzeh wants to merge 87 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
…n showcase test sessions
b014e36 to
0dc81e3
Compare
…all in showcase_library
…-api-core in showcase sessions
…in pyproject.toml
… to match client.py.j2
| "-p", | ||
| "google", | ||
| "--check-untyped-defs", | ||
| ) |
There was a problem hiding this comment.
Is this change related? Why is this here?
| [tool.setuptools.package-data] | ||
| "google.api_core" = ["py.typed"] | ||
| "*" = ["py.typed"] | ||
|
|
There was a problem hiding this comment.
Same question: Why is this here?
| ) | ||
| assert len(cgr.file) == 1 | ||
| assert cgr.file[0].name == "foo/bar/baz.py" | ||
| assert cgr.file[0].content == "I am a template result.\n" |
There was a problem hiding this comment.
Why were these assertions removed?
| # Install the library without a constraints file. | ||
| session.install("-e", tmp_dir) | ||
|
|
||
| session.install("-e", "../google-api-core", "--no-deps") |
There was a problem hiding this comment.
Can you clarify why this is needed? This is causing mypy to fail btw
|
|
||
| from .rest_base import _BaseStorageBatchOperationsRestTransport | ||
| from google.cloud.storagebatchoperations_v1.storage_batch_operations._compat import transcode_request | ||
| from google.cloud.storagebatchoperations_v1._compat import transcode_request |
There was a problem hiding this comment.
I think I mentioned this in a different PR, but can we have _compat in the service directory?
| def _get_unset_required_fields(cls, message_dict): | ||
| return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} | ||
| _REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { | ||
| "updateMask" : {}, } |
There was a problem hiding this comment.
nit: the indentation is a bit off on these
| except ImportError: # pragma: NO COVER | ||
| from google.auth.transport import mtls # type: ignore | ||
|
|
||
| # 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.
I mentioned this in a different PR, but 2.18.0 seems like the wrong version
| "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be" | ||
| " either `true` or `false`" | ||
| ) | ||
| return use_client_cert_str == "true" |
There was a problem hiding this comment.
I don't think these were indended to be here? This was a separate PR, but use_client_cert_effective shouldn't be in api_core, since it's already in google-auth
You can add a compat function for this if you want, but it should probably come in a separate change:
try:
from google.auth.....mtls import should_use_client_cert
except ImportError:
def should_use_client_cert():
...
|
To simplify things for myself and the review process I am going to break things down:
|
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: