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 grpc transcoding, clean up unimplemented rest method/test generation by yon-mg · Pull Request #776 · googleapis/gapic-generator-python

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

Conversation

@yon-mg

@yon-mg yon-mg commented Feb 13, 2021

Copy link
Copy Markdown
Contributor

This pr introduces usage of grpc transcoding and is reliant on changes made to to,
googleapis/python-api-core#146.

With this implementation of grpc transcoding, there are a few more changes that need to be made to ensure Showcase tests can run correctly. LRO rpcs, streaming rpcs and rpcs without google.api.http annotations need to also be handled. In this pr they are not implemented fully and instead rather raise errors if used in a generated client. The intention is to implement them at a later time and remove them as temporary blockers to push the grpc transcoding changes.

Sorry, something went wrong.

Uh oh!

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

All reactions
yon-mg and others added 11 commits January 25, 2021 18:14
@yon-mg
fix: update paging implementation to handle unconventional pagination
1141010
@yon-mg
Merge remote-tracking branch 'upstream/master'
058b55e
@yon-mg
fix: typing errors, mypy cli update
d226f36
@yon-mg
fix: mypy cli flag
01adad1
@yon-mg
fix: delete __init__.py, remove -p mypy flag
0f3e63d
@yon-mg
fix: clearing up statements, tests, minor bug in filter usage
48253d3
@yon-mg
fix: wrong genereated type hints
86e2c43
@yon-mg
Merge branch 'master' into master
959e1a0
@yon-mg
feat: add grpc_transcoding, clean up rest generation unimplemented me…
5f1ba34
…thods/tests
@yon-mg
Merge branch 'master' of github.com:yon-mg/gapic-generator-python
82c91b8
@yon-mg
Merge remote-tracking branch 'upstream/master'
31a442b
@yon-mg
yon-mg requested review from a team, software-dov, vam-google and vchudnov-g February 13, 2021 02:33
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Feb 13, 2021
@codecov

codecov Bot commented Feb 13, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Codecov Report

Merging #776 (73b6044) into master (7c185e8) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #776   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           26        27    +1     
  Lines         1608      1642   +34     
  Branches       328       333    +5     
=========================================
+ Hits          1608      1642   +34     
Impacted Files Coverage Δ
gapic/utils/case.py 100.00% <ø> (ø)
gapic/generator/generator.py 100.00% <100.00%> (ø)
gapic/schema/wrappers.py 100.00% <100.00%> (ø)
gapic/utils/__init__.py 100.00% <100.00%> (ø)
gapic/utils/checks.py 100.00% <100.00%> (ø)

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 d2fe3c6...73b6044. Read the comment docs.

All reactions

Sorry, something went wrong.

Uh oh!

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

software-dov
software-dov reviewed Feb 17, 2021
View reviewed changes
Comment thread gapic/schema/wrappers.py

for http_rule in http_options:
try:
method, uri = next((method, uri) for method,uri in [

@software-dov software-dov Feb 17, 2021

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.

Formatting nit: for method, uri

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread gapic/schema/wrappers.py
Comment on lines +761 to +771
method, uri = next((method, uri) for method,uri in [
('get',http_rule.get),
('put',http_rule.put),
('post',http_rule.post),
('delete',http_rule.delete),
('patch',http_rule.patch),
('custom.path',http_rule.custom.path),
] if uri
)
except StopIteration:
continue

@software-dov software-dov Feb 17, 2021

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.

I think it's better not to catch a StopIteration and instead use explicit control flow.
This is a fairly common pattern when using next:

thing = next((generator_expression_or_iterable), None) # Or (None, None) if detupling
if not thing:
    continue # Or do some other action

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2
Comment on lines +228 to +232
@property
def {{ method.name|snake_case }}(self) -> Callable[
[{{ method.input.ident }}],
{{ method.output.ident }}]:
return self._{{ method.name|snake_case }}

@software-dov software-dov Feb 17, 2021

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.

Why the extra indirection? Is it removable?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2
Comment on lines +179 to +184
# Jsonify the query params
query_params = json.loads({{ method.input.ident }}.to_json(
{{ method.input.ident }}(transcoded_request['query_params']),
including_default_value_fields=False,
use_integers_for_enums=False
))

@software-dov software-dov Feb 17, 2021

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.

Unless I'm misunderstanding something, this is turning the transcoded request back into a Request message object, turning it into a JSON string, and then turning it back into a python dict. Is that correct? Can we use to_dict instead of the indirection?
If the above is correct, can you add some comments describing the dataflow? If it's not correct, then could you describe what the dataflow is?

Sorry, something went wrong.

Uh oh!

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

All reactions

@kbandes kbandes Sep 9, 2021

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.

for the record: this is actually not redundant, provided we want to rely on proto+ to do the proper case conversion. to_dict doesn't do the conversion from snake_case to camelCase, only to_json does that. But the result of to_json is a string that can't be used as-is to construct the query string.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2
return {{ method.output.ident }}.from_json(response.content)
{%- else %}

# Returh the response

@software-dov software-dov Feb 17, 2021

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.

Nit: Return the response

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread gapic/templates/tests/unit/gapic/%name_%version/%sub/test_%service.py.j2
{%- endfor %}
)

<<<<<<< HEAD

@software-dov software-dov Feb 17, 2021

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.

Cruft

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread gapic/templates/tests/unit/gapic/%name_%version/%sub/test_%service.py.j2
{%- endif %} in http_call[1] + str(body) + str(query_params.values())
{% endif %}
{% endif %}{% endfor %}
=======

@software-dov software-dov Feb 17, 2021

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.

Cruft

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread gapic/templates/tests/unit/gapic/%name_%version/%sub/test_%service.py.j2
{%- endif %} in http_call[1] + str(body)
{% endif %}
{% endif %}{% endfor %}
>>>>>>> upstream/master

@software-dov software-dov Feb 17, 2021

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.

Cruft

Sorry, something went wrong.

Uh oh!

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

All reactions
@software-dov
Merge branch 'master' into master
73b6044
@software-dov
software-dov requested a review from lukesneeringer as a code owner February 17, 2021 19:46
@parthea parthea assigned yon-mg Aug 4, 2021
@parthea

parthea commented Aug 14, 2021

Copy link
Copy Markdown
Contributor

Hi @yon-mg , I'm going to close this PR due to inactivity but please feel free to re-open it.

All reactions

Sorry, something went wrong.

Uh oh!

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

@parthea parthea closed this Aug 14, 2021
@vam-google vam-google reopened this Sep 1, 2021
@vam-google

vam-google commented Sep 1, 2021

Copy link
Copy Markdown
Contributor

This is still needed for REGAPIC Python. Please do not close it.

All reactions

Sorry, something went wrong.

Uh oh!

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

@kbandes kbandes mentioned this pull request Sep 14, 2021
feat: Support alternative http bindings in the gapic schema. #993
Merged
@software-dov software-dov closed this Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@vchudnov-g vchudnov-g Awaiting requested review from vchudnov-g
@vam-google vam-google Awaiting requested review from vam-google
@lukesneeringer lukesneeringer Awaiting requested review from lukesneeringer
2 more reviewers
@kbandes kbandes kbandes left review comments
@software-dov software-dov software-dov left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

@yon-mg yon-mg

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.

5 participants

@yon-mg @parthea @vam-google @kbandes @software-dov
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.