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 — fix: updating testing, rest-only generation, & minor bug-fixes by yon-mg · Pull Request #716 · 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 Dec 21, 2020

Copy link
Copy Markdown
Contributor

Updating unit tests on generated client rest transport. Most changes made to unit tests are with compute api in mind and are not yet comprehensive enough for showcase.

Fixed issues with rest-only transport generation. Again, changes made with compute api in mind especially since compute api doesn't have grpc endpoint.

Fixed bug with attribute keyword conflicts.

The goal with this PR is to be able to generate a minimum usable GCE client library. Since rest transport is still under work, it is not generated by default and must be set with the transport flag --python_gapic_opt="transport=grpc+rest".

Sorry, something went wrong.

Uh oh!

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

busunkim96 reacted with hooray emoji
All reactions
  • 🎉 1 reaction
yon-mg and others added 30 commits November 2, 2020 17:49
@yon-mg
feat: add rest transport generation for clients
c1a6f89
@yon-mg
feat: add rest transport generation for clients
bd7c32d
@yon-mg
Merge branch 'master' of github.com:yon-mg/gapic-generator-python
cd3a7f1
@yon-mg
feat: add transport flag
b41db31
@yon-mg
refactor: moved template logic outside
ce69e7d
@yon-mg
fix: small fixes in transport option logic
89fa08b
@yon-mg
test: added unit test for transport flag
86f3a9c
@yon-mg
test: add unit test for http option method
234cc09
@yon-mg
test: add unit test for http option method branch
35ac276
@yon-mg
fix: fix import paths
c8155a5
@yon-mg
fix: style check issues
55a815c
@yon-mg
fix: more style check issues
ac0bdef
@yon-mg
fix: addressing pr reviews
e79e8c7
@yon-mg
fix: typo in test_method
824ad11
@yon-mg
fix: style check fixes
2d11e19
@yon-mg
Merge branch 'master' into master
b5c6d06
@yon-mg
feat: add proper handling of query/path/body parameters for rest tran…
221cd44
…sport
@yon-mg
Merge branch 'master' of github.com:yon-mg/gapic-generator-python
475f903
@yon-mg
Merge remote-tracking branch 'upstream/master'
f08ca32
@yon-mg
fix: typing errors
efa0ed6
@software-dov
Update case.py
d3e08c0
@yon-mg
fix: minor changes adding a test, refactor and style check
df88ef9
@yon-mg
Merge branch 'master' of github.com:yon-mg/gapic-generator-python
67c6bd1
@yon-mg
fix: camel_case bug with constant case
37e3d28
@yon-mg
fix: to_camel_case to produce lower camel case instead of PascalCase …
c964fba
…where relevant
@yon-mg
fix: addressing pr comments
85be88d
@yon-mg
fix: adding appropriate todos, addressing comments
5d1c6a3
@yon-mg
fix: dataclass dependency issue
f6c64cc
@software-dov
Update wrappers.py
a4f34e7
@yon-mg
Merge remote-tracking branch 'upstream/master'
df8124b
@yon-mg
yon-mg requested a review from vam-google December 21, 2020 16:16
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Dec 21, 2020
@yon-mg
yon-mg marked this pull request as draft December 21, 2020 16:16
@yon-mg yon-mg changed the title fix: updating testing, rest-only generation, & minor bug-fixes fix(WIP): updating testing, rest-only generation, & minor bug-fixes Dec 21, 2020
vam-google
vam-google reviewed Dec 22, 2020
View reviewed changes
Comment thread gapic/templates/tests/unit/gapic/%name_%version/%sub/test_%service.py.j2
import pytest
from proto.marshal.rules.dates import DurationRule, TimestampRule

from requests import Response

@vam-google vam-google Dec 21, 2020

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.

Should this be under "if" statements?

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
@pytest.mark.parametrize("client_class", [{{ service.client_name }}, {{ service.async_client_name }}])
@pytest.mark.parametrize("client_class", [
{{ service.client_name }},
{%- if 'grpc' in opts.transport %}

@vam-google vam-google Dec 22, 2020

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.

This construct is used everywhere in the template. Since it is so commonly used, please consider simplifying it by introducing some helper method, such that it look something like:

{%- if grpc %}
stuff
{%- endif %}

Sorry, something went wrong.

Uh oh!

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

All reactions
yon-mg added 4 commits December 22, 2020 22:07
@yon-mg
fix: fixed reserved keyword bug, fixed bugs in gapic tests
cc5ae23
@yon-mg
fix: reverted bug causing change to , refactored template tests
34b4b5d
@yon-mg
fix: return type mismatch
06bfd2e
@yon-mg
fix: reserved keyword issue in
53771e9
@codecov

codecov Bot commented Dec 23, 2020 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Codecov Report

Merging #716 (7058f62) into master (f646767) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #716   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           26        27    +1     
  Lines         1608      1619   +11     
  Branches       328       328           
=========================================
+ Hits          1608      1619   +11     
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 f646767...7058f62. Read the comment docs.

All reactions

Sorry, something went wrong.

Uh oh!

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

@yon-mg
yon-mg marked this pull request as ready for review December 23, 2020 17:33
vam-google
vam-google reviewed Dec 23, 2020
View reviewed changes
Comment thread gapic/utils/checks.py Outdated
import re


def is_str(expr: str) -> bool:

@vam-google vam-google Dec 23, 2020

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.

If this file is used only for testing, please put it where the testing code is. Also please make sure that we don't do anything like this (guessting field type by its value, and using regexps for it), because it is not reliable enough and is quite slow (the regexp part).

Sorry, something went wrong.

Uh oh!

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

All reactions
@vam-google

vam-google commented Dec 23, 2020

Copy link
Copy Markdown
Contributor

@software-dov PTAL. This is the last PR which blocks us from generating the first Pyghon Alpha client for GCE!

All reactions

Sorry, something went wrong.

Uh oh!

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

vam-google
vam-google reviewed Dec 23, 2020
View reviewed changes
Comment thread gapic/utils/checks.py Outdated
@@ -0,0 +1,42 @@
# Copyright 2018 Google LLC

@vam-google vam-google Dec 23, 2020

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.

Please use field.type instead field.mock_value in your test templates. By doing that you may avoid guessing work here, as we discussed over GVC. Also, please update copyright to 2020 here and in all your new files.

Sorry, something went wrong.

Uh oh!

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

All reactions
@yon-mg
fix: replace bad regex checks with checks against field_pb type
85a983d
busunkim96
busunkim96 reviewed Dec 28, 2020
View reviewed changes

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

Looks good to me (I am not an expert on the generator so deferring to other folks for approvals). I'm excited to try this out! 🚀

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread gapic/templates/noxfile.py.j2 Resolved

Uh oh!

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

Comment thread gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2
Comment on lines +189 to +190
query_params = ['{k}={v}'.format(k=k, v=v) for k, v in query_params.items() if v]
url += '?{}'.format('&'.join(query_params)).replace(' ', '+')

@busunkim96 busunkim96 Dec 28, 2020

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.

It might be easier to use urllib.parse.urlencode here (It will create the k=v structure and glue the pairs together with & characters).

https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlencode
https://docs.python.org/3/library/urllib.request.html#urllib-examples

Sorry, something went wrong.

Uh oh!

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

All reactions

@yon-mg yon-mg Dec 28, 2020

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.

Not sure how I missed this. Thanks!

Sorry, something went wrong.

Uh oh!

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

All reactions

@yon-mg yon-mg Dec 30, 2020

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.

To clarify, I'll leave this out for now so I don't accidentally break anything but I'll update in the subsequent PR

Sorry, something went wrong.

Uh oh!

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

All reactions
@busunkim96 busunkim96 mentioned this pull request Dec 28, 2020
fix: fix get_field for reserved names in field path #722
Closed
@yon-mg yon-mg changed the title fix(WIP): updating testing, rest-only generation, & minor bug-fixes fix: updating testing, rest-only generation, & minor bug-fixes Dec 28, 2020
software-dov
software-dov approved these changes Dec 30, 2020
View reviewed changes
yon-mg and others added 2 commits December 30, 2020 15:02
@yon-mg @busunkim96
Update gapic/templates/noxfile.py.j2
638a639
Co-authored-by: Bu Sun Kim <[email protected]>
@yon-mg
Merge branch 'master' into master
7058f62
@yon-mg
yon-mg merged commit 56c31de into googleapis:master Dec 30, 2020
vchudnov-g
vchudnov-g reviewed Jan 5, 2021
View reviewed changes

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

Did a quick once-over. Looks good! Thanks for doing this.

Two very minor comments.

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 %}

{% if "next_page_token" in method.output.fields.values()|map(attribute='name') and not method.paged_result_field %}
{# Cheeser assertion to force code coverage for bad paginated methods #}

@vchudnov-g vchudnov-g Jan 5, 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.

What does "cheeser" mean in this context?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread tests/unit/generator/test_generator.py
"foo/some_service/transports/car.py",
"foo/some_service/transports/__init__.py",
"foo/some_service/transports/base.py",
# Only generate async client with grpc transport

@vchudnov-g vchudnov-g Jan 5, 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: This comment looks as thought it applies to the next line, but is a bit confusing. Suggest moving it below the next line and tweaking it to be something like: # no async_client.py, as that's only for grpc transport

Sorry, something went wrong.

Uh oh!

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

All reactions
@vchudnov-g vchudnov-g mentioned this pull request Jan 5, 2021
feat: Python DIREGAPIC initial commit googleapis/googleapis-discovery#14
Merged
@busunkim96 busunkim96 linked an issue Jan 6, 2021 that may be closed by this pull request
Re-add HTTP transport and make it the fallback #267
Closed
This was referenced Jan 18, 2022
chore(master): release reverted #1133
Merged
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

4 more reviewers
@vchudnov-g vchudnov-g vchudnov-g left review comments
@busunkim96 busunkim96 busunkim96 left review comments
@vam-google vam-google vam-google left review comments
@software-dov software-dov software-dov 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.

Re-add HTTP transport and make it the fallback

Uh oh!

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

5 participants

@yon-mg @vam-google @software-dov @vchudnov-g @busunkim96
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.