Skip to content

Conversation

@gkevinzheng
Copy link
Contributor

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

@gkevinzheng gkevinzheng requested a review from parthea December 4, 2024 16:07
@gkevinzheng gkevinzheng requested a review from a team as a code owner December 4, 2024 16:07
@product-auto-label product-auto-label bot added the size: xl Pull request size is extra large. label Dec 4, 2024
@snippet-bot
Copy link

snippet-bot bot commented Dec 4, 2024

Here is the summary of changes.

You are about to add 10 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

Copy link
Contributor

@parthea parthea left a 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

@parthea
Copy link
Contributor

parthea commented Dec 18, 2024

Requesting review from @vchudnov-g as well

@parthea parthea requested a review from vchudnov-g December 18, 2024 18:22
@parthea parthea changed the title feat: Selective GAPIC phase 1 feat: Add support for reading selective GAPIC generation methods from service YAML Dec 18, 2024
Copy link
Contributor

@vchudnov-g vchudnov-g left a 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.

return self.disambiguate(f'_{string}')
return string

def build_address_allowlist_for_selective_gapic(self, *,
Copy link
Contributor

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.

return self.disambiguate(f'_{string}')
return string

def build_address_allowlist_for_selective_gapic(self, *,
Copy link
Contributor

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)

}

# 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
Copy link
Contributor

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.

Copy link
Contributor Author

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

@vchudnov-g
Copy link
Contributor

Meta-comment: please do not merge main while a PR is being reviewed; it makes it much harder to see the incremental changes relevant only to the PR. I suggest merging main before sending out for the initial review, and after the PR is approved when you're ready to commit the PR to main (and if the merge changes are non-trivial, a second round of review could be reasonable, but that seems to be rare).


def test_python_settings_selective_gapic_version_mismatch_method_raises_error():
"""
Test that `ClientLibrarySettingsError` is raised when there are nonexistent methods in
Copy link
Contributor

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:

Suggested change
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

Comment on lines 2893 to 2894
assert len(api_schema.all_protos) == 3
assert len(api_schema.protos) == 2
Copy link
Contributor

@vchudnov-g vchudnov-g Jan 25, 2025

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?

Suggested change
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

Copy link
Contributor

@vchudnov-g vchudnov-g left a 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!

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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)

@gkevinzheng gkevinzheng added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 27, 2025
@gkevinzheng gkevinzheng merged commit 3a1a91c into main Jan 28, 2025
125 checks passed
@gkevinzheng gkevinzheng deleted the selective-gapic-p1 branch January 28, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kokoro:force-run Add this label to force Kokoro to re-run the tests. size: xl Pull request size is extra large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants