Skip to content
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

feat: add autogenerated snippets #845

Merged
merged 26 commits into from May 3, 2021
Merged

feat: add autogenerated snippets #845

merged 26 commits into from May 3, 2021

Conversation

busunkim96
Copy link
Contributor

This PR targets iteration 1 and 2 specified in the Snippet Gen Design: Full canonical coverage of simple requests, paginated, LRO, server streaming, and Bidi streaming with empty request objects.

Snippet generation is hidden behind a new option autogen-snippets.

After discussion with folks on different language teams on snippetgen, I decided using "golden" snippet files would be easier than following the unit testing strategy used to check the library surface. I also believe goldens will be be easier for review for other Python DPEs.

Other notes:

  • I've commented out the existing metadata generation code and tests. The new metadata format is still under discussion.
  • Async samples are excluded as the existing samplegen infrastructure was written pre-async. I will add the async samples in the next PR.

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Apr 23, 2021
@snippet-bot
Copy link

snippet-bot bot commented Apr 23, 2021

Here is the summary of possible violations 😱

There are 7 possible violations for not having product prefix.

The end of the violation section. All the stuff below is FYI purposes only.


Here is the summary of changes.

You are about to add 7 region tags.
You are about to delete 2 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

@codecov
Copy link

codecov bot commented Apr 23, 2021

Codecov Report

Merging #845 (ce309df) into master (7c185e8) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #845   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           26        27    +1     
  Lines         1608      1694   +86     
  Branches       328       347   +19     
=========================================
+ Hits          1608      1694   +86     
Impacted Files Coverage Δ
gapic/samplegen_utils/types.py 100.00% <ø> (ø)
gapic/samplegen_utils/utils.py 100.00% <ø> (ø)
gapic/utils/case.py 100.00% <ø> (ø)
gapic/utils/reserved_names.py 100.00% <ø> (ø)
gapic/generator/generator.py 100.00% <100.00%> (ø)
gapic/samplegen/samplegen.py 100.00% <100.00%> (ø)
gapic/schema/api.py 100.00% <100.00%> (ø)
gapic/schema/metadata.py 100.00% <100.00%> (ø)
gapic/schema/wrappers.py 100.00% <100.00%> (ø)
gapic/utils/__init__.py 100.00% <100.00%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 358a702...ce309df. Read the comment docs.

@busunkim96
Copy link
Contributor Author

Lol please ignore snippetbot, I'll add a config to ignore those paths.

@busunkim96 busunkim96 marked this pull request as ready for review April 23, 2021 23:02
@busunkim96 busunkim96 requested review from a team as code owners April 23, 2021 23:02
@software-dov
Copy link
Contributor

I'm honestly surprised as much of the original sample gen code is as reusable as seems to be the case. Neat!
It looks like both golden test artifacts and the .test_output artifacts are added to this PR; should .test_output be added to .gitignore?

First pass looks great, going to look more closely in just a second.

Copy link
Contributor

@software-dov software-dov left a comment

Choose a reason for hiding this comment

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

Just a few minor nits. Looks great!

gapic/templates/examples/feature_fragments.j2 Outdated Show resolved Hide resolved
gapic/templates/examples/sample.py.j2 Outdated Show resolved Hide resolved
noxfile.py Show resolved Hide resolved
tests/snippetgen/test_snippetgen.py Outdated Show resolved Hide resolved
Copy link

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

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

LGTM on the functional side of things.

I just left a comment re: region tags. Thanks!!

for client_name, client in service.clients.items():

for rpc_name, method_list in client.rpcs.items():
# generated_${api}_${apiVersion}_${serviceName}_${rpcName}_{sync|async}

Choose a reason for hiding this comment

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

This is going to change now so that snippets can be matched to products by the snippet tracker. @busunkim96 I've cc'ed you on a comment on the desgin doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed! One thing I noticed is that the endpoint is declared at the service level. I guess in practice the endpoint is the same across all services in the same API? https://github.com/googleapis/googleapis/blob/ae5fb2884a296832c39867e8e8c81bbc72a32ce8/google/cloud/pubsublite/v1/subscriber.proto#L35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants