GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: add autogenerated snippets by busunkim96 · Pull Request #845 · googleapis/gapic-generator-python

This repository was archived by the owner on Aug 25, 2026. It is now read-only.

Conversation

@busunkim96

@busunkim96 busunkim96 commented Apr 23, 2021

Copy link
Copy Markdown
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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
busunkim96 added 16 commits April 22, 2021 17:17
@busunkim96
feat: change sampels to align with new design
701476f
@busunkim96
feat: fulfill requirements for P0 snippetgen
c998993
@busunkim96
fix: fix type issues
6149983
@busunkim96
fix: disable autogen snippets by default
63a0509
@busunkim96
fix: resolve mypy issues
793d108
@busunkim96
fix: use trim_blocks and lstrip_blocks for jinja templates
be303df
@busunkim96
fix: fix more templates
c4f95cf
@busunkim96
fix: fix sample unit tests
1666d0a
@busunkim96
test: add separate snippetgen session and basic golden snippet
23df2f3
@busunkim96
test: get existing unit tests to pass
a302db9
@busunkim96
chore: comment out manifest gen
093f931
@busunkim96
chore: tweak dummy ident in tests
2de6ac8
@busunkim96
feat: fill out basic snippets for other types
ee1897c
@busunkim96
Merge branch 'master' into snippet-gen
6b46aab
@busunkim96
fix: properly resolve merge conflict
0944178
@busunkim96
chore: comment cleanup
a487f7d
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Apr 23, 2021
@busunkim96
Merge branch 'master' into snippet-gen
351f0fe
@snippet-bot

snippet-bot Bot commented Apr 23, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Here is the summary of possible violations 😱

Details

There are 7 possible violations for not having product prefix.
  • tests/snippetgen/goldens/mollusca_generated_mollusca_v1_snippets_list_resources_grpc.py:26, tag mollusca_generated_mollusca_v1_Snippets_ListResources_grpc
  • tests/snippetgen/goldens/mollusca_generated_mollusca_v1_snippets_method_bidi_streaming_grpc.py:26, tag mollusca_generated_mollusca_v1_Snippets_MethodBidiStreaming_grpc
  • tests/snippetgen/goldens/mollusca_generated_mollusca_v1_snippets_method_lro_signatures_grpc.py:26, tag mollusca_generated_mollusca_v1_Snippets_MethodLroSignatures_grpc
  • tests/snippetgen/goldens/mollusca_generated_mollusca_v1_snippets_method_one_signature_grpc.py:26, tag mollusca_generated_mollusca_v1_Snippets_MethodOneSignature_grpc
  • tests/snippetgen/goldens/mollusca_generated_mollusca_v1_snippets_method_server_streaming_grpc.py:26, tag mollusca_generated_mollusca_v1_Snippets_MethodServerStreaming_grpc
  • tests/unit/samplegen/golden_snippets/sample_basic.py:26, tag mollusc_classify_sync
  • tests/unit/samplegen/golden_snippets/sample_basic_unflattenable.py:26, tag mollusc_classify_sync

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.
  • tests/snippetgen/goldens/mollusca_generated_mollusca_v1_snippets_list_resources_grpc.py:26, tag mollusca_generated_mollusca_v1_Snippets_ListResources_grpc
  • tests/snippetgen/goldens/mollusca_generated_mollusca_v1_snippets_method_bidi_streaming_grpc.py:26, tag mollusca_generated_mollusca_v1_Snippets_MethodBidiStreaming_grpc
  • tests/snippetgen/goldens/mollusca_generated_mollusca_v1_snippets_method_lro_signatures_grpc.py:26, tag mollusca_generated_mollusca_v1_Snippets_MethodLroSignatures_grpc
  • tests/snippetgen/goldens/mollusca_generated_mollusca_v1_snippets_method_one_signature_grpc.py:26, tag mollusca_generated_mollusca_v1_Snippets_MethodOneSignature_grpc
  • tests/snippetgen/goldens/mollusca_generated_mollusca_v1_snippets_method_server_streaming_grpc.py:26, tag mollusca_generated_mollusca_v1_Snippets_MethodServerStreaming_grpc
  • tests/unit/samplegen/golden_snippets/sample_basic.py:26, tag mollusc_classify_sync
  • tests/unit/samplegen/golden_snippets/sample_basic_unflattenable.py:26, tag mollusc_classify_sync
You are about to delete 2 region tags.
  • tests/unit/samplegen/test_integration.py:135, tag %s
  • tests/unit/samplegen/test_integration.py:271, tag %s

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
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codecov

codecov Bot commented Apr 23, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@busunkim96

busunkim96 commented Apr 23, 2021

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

busunkim96 added 4 commits April 23, 2021 22:14
@busunkim96
test: fix protoc installation, add snippetgen tests
0ba949c
@busunkim96
Merge branch 'snippet-gen' of github.com:googleapis/gapic-generator-p…
0425783
…ython into snippet-gen
@busunkim96
fix: fix style
769e06f
@busunkim96
chore: tell snippetgen to ignore this repo
e6224a6
@busunkim96
busunkim96 marked this pull request as ready for review April 23, 2021 23:02
@busunkim96
busunkim96 requested review from a team, amanda-tarafa and software-dov April 23, 2021 23:02
@software-dov

software-dov commented Apr 27, 2021

Copy link
Copy Markdown
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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

software-dov
software-dov reviewed Apr 27, 2021
View reviewed changes

@software-dov software-dov left a comment

Copy link
Copy Markdown
Contributor

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.

Just a few minor nits. Looks great!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread gapic/templates/examples/feature_fragments.j2 Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread gapic/templates/examples/sample.py.j2 Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread noxfile.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/snippetgen/test_snippetgen.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

amanda-tarafa
amanda-tarafa approved these changes Apr 28, 2021
View reviewed changes

@amanda-tarafa amanda-tarafa left a comment

Copy link
Copy Markdown

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 on the functional side of things.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread gapic/generator/generator.py Outdated
for client_name, client in service.clients.items():

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

@amanda-tarafa amanda-tarafa Apr 28, 2021

Copy link
Copy Markdown

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 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@busunkim96 busunkim96 May 3, 2021

Copy link
Copy Markdown
Contributor Author

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.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
busunkim96 added 4 commits May 3, 2021 21:48
@busunkim96
fix: address review comments
0fce06c
@busunkim96
fix: re-add templates on jinja files
3c3cb5a
@busunkim96
chore: ignore test_output dir
b218789
@busunkim96
test: add default host to gen sample spec test
cca0f54
software-dov
software-dov approved these changes May 3, 2021
View reviewed changes
@software-dov
Merge branch 'master' into snippet-gen
ce309df
@busunkim96
busunkim96 merged commit abdf5ec into master May 3, 2021
@busunkim96
busunkim96 deleted the snippet-gen branch May 3, 2021 22:49
This was referenced Jan 18, 2022
chore(master): release reverted #1133
Merged
chore(master): release 0.40.0 #1138
Closed
chore(master): release 0.39.1 #1146
Closed
This was referenced Jan 26, 2022
chore(main): release 0.39.1 #1160
Closed
chore(main): release 0.39.1 #1162
Closed
chore(main): release 0.61.0 #1163
Merged
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

2 more reviewers
@software-dov software-dov software-dov approved these changes
@amanda-tarafa amanda-tarafa amanda-tarafa approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@busunkim96 @software-dov @amanda-tarafa
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.