feat(generator): gapic generator centralization routing - #17816
feat(generator): gapic generator centralization routing#17816hebaalazzeh wants to merge 34 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new compatibility template _compat.py.j2 to provide fallback implementations for get_default_mtls_endpoint, get_api_endpoint, and get_universe_domain when they are not available in google.api_core.universe. The client templates are updated to delegate these operations to the new compatibility module, and redundant unit tests are removed from the generated test suites. The review feedback highlights that both get_api_endpoint in _compat.py.j2 and _get_api_endpoint in client.py.j2 can return None under certain conditions, and recommends updating their return type annotations to Optional[str] for better type safety.
b8ed069 to
b7054c2
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a compatibility module template _compat.py.j2 to centralize fallback logic for older versions of google-api-core, updating the generator and client templates to import and use these shared utilities. Feedback on the changes highlights two critical issues regarding generated files: first, the new mock.patch("os.path.exists", ...) in the golden files is missing from the generator's template test_%service.py.j2; second, the new test file test__compat.py was added directly to a golden directory without a corresponding template, which will cause integration test failures.
f61bfa7 to
a89c8ca
Compare
9954e16 to
0547563
Compare
This PR refactors the generated client templates to utilize centralized endpoint routing and universe domain logic.
_get_default_mtls_endpoint,_get_api_endpoint, and_get_universe_domainfrom generated client classes to the compatibility layer (_compat.py)._compat.pyto maintain compatibility with oldergoogle-api-coreversions, laying groundwork for importing directly fromgoogle.api_core.universe(centralized in PR feat(api-core): add get_universe_domain helper to universe.py #17799) once the minimum dependency is bumped.test_%service.py.j2totest_compat.py.j2.Towards: #17883