-
Notifications
You must be signed in to change notification settings - Fork 76
feat: Add support for reading selective GAPIC generation methods from service YAML #2272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
8f9db43 to
2274254
Compare
2274254 to
55d0cca
Compare
parthea
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but holding off on formal approval until tomorrow after the next release is shipped
|
Requesting review from @vchudnov-g as well |
vchudnov-g
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is looking good, but I have some questions/suggestions. PTAL.
gapic/schema/api.py
Outdated
| return self.disambiguate(f'_{string}') | ||
| return string | ||
|
|
||
| def build_address_allowlist_for_selective_gapic(self, *, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In our code base (including comments), I would use a clearer name that "selective GAPIC"; I find it a bit of a misnomer. We're not selecting the GAPIC; we're selecting the RPCs to create a custom (non-standard) GAPIC. So I would have us choose one of selective_generation or custom_gapic and use that as the affix consistently everywhere, instead of selective_gapic.
gapic/schema/api.py
Outdated
| return self.disambiguate(f'_{string}') | ||
| return string | ||
|
|
||
| def build_address_allowlist_for_selective_gapic(self, *, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I've not seen the word address used in this context and I wish we weren't using it, but I see it's prior art already in use. Oh, well)
gapic/schema/api.py
Outdated
| } | ||
|
|
||
| # For messages and enums we should only be pruning them from all_messages if they | ||
| # are proto plus types. This should apply to the Protos we are pruning from, but might |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"but might not in the future."
WDYM? This seems cryptic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we trying to move away from proto plus types? I'll remove the "in the future part" regardless
Co-authored-by: Victor Chudnovsky <vchudnov@google.com>
Co-authored-by: Victor Chudnovsky <vchudnov@google.com>
|
Meta-comment: please do not merge |
tests/unit/schema/test_api.py
Outdated
|
|
||
| def test_python_settings_selective_gapic_version_mismatch_method_raises_error(): | ||
| """ | ||
| Test that `ClientLibrarySettingsError` is raised when there are nonexistent methods in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To highlight the difference with the previous test:
| Test that `ClientLibrarySettingsError` is raised when there are nonexistent methods in | |
| Test that `ClientLibrarySettingsError` is raised when a method listed for selective generation exists only in a different version of the library |
tests/unit/schema/test_api.py
Outdated
| assert len(api_schema.all_protos) == 3 | ||
| assert len(api_schema.protos) == 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make this more informative to someone figuring out this part of our architecture (including me, as I double-check my understanding I gleaned from looking at your PR), could you add some comments? In particular, is the following correct?
| assert len(api_schema.all_protos) == 3 | |
| assert len(api_schema.protos) == 2 | |
| assert len(api_schema.all_protos) == 3 # foo.proto, common.proto, dep.proto | |
| assert len(api_schema.protos) == 2 # foo.proto, common.proto |
vchudnov-g
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Please address open comments from previous reviews before you merge. Thank you so much for doing this!
tests/unit/schema/test_api.py
Outdated
| assert 'bar.proto' not in api_schema.protos | ||
| assert 'bar_common.proto' not in api_schema.protos | ||
|
|
||
| # Check that the sub-packages have been completely pruned are excluded from generation, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # Check that the sub-packages have been completely pruned are excluded from generation, | |
| # Check that the sub-packages that have been completely pruned are excluded from generation, |
(I accidentally omitted this word in my suggestion in a previous round of review)
This PR implements Selective GAPIC generation for Python. For more details, see:
Overall design doc: go/selective-gapic-generation
Implementation doc for Python: go/selective-gapic-gen-python