-
Notifications
You must be signed in to change notification settings - Fork 69
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
fix(snippetgen): fix client streaming samples #1061
Merged
+70
−80
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8d602bb
fix(snippetgen) fix streaming samples
busunkim96 b6c56aa
test: fix tests
busunkim96 06407c7
test: delete obsolete tests, ignore snippetgen goldens for autopep8
busunkim96 80d33cb
chore: update .github
busunkim96 4c6adb4
Merge branch 'master' into fix-streaming-samples
busunkim96 4dc4db9
Merge branch 'master' into fix-streaming-samples
busunkim96 4c7710b
Merge branch 'master' into fix-streaming-samples
tseaver File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,8 +38,17 @@ async def sample_tail_log_entries(): | |
resource_names=['resource_names_value_1', 'resource_names_value_2'], | ||
) | ||
|
||
# This method expects an iterator which contains | ||
# 'logging_v2.TailLogEntriesRequest' objects | ||
# Here we create a generator that yields a single `request` for | ||
# demonstrative purposes. | ||
requests = [request] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One simpler alternative is: requests = iter([requests]) I chose the generator over Opinions/suggestions on the best way to present client streaming welcome! |
||
def request_generator(): | ||
for request in requests: | ||
yield request | ||
|
||
# Make the request | ||
stream = await client.tail_log_entries([resource_names=['resource_names_value_1', 'resource_names_value_2']]) | ||
stream = await client.tail_log_entries(requests=request_generator()) | ||
async for response in stream: | ||
print(response) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
@software-dov 👋 I'm having trouble understanding this error, would you remember what this was written to prevent?
Some streaming method request messages have 2+ required fields (pubsub), so the current snippetgen logic adds two
field
s to the dictionary. That causes this error to be raised. Are fields expected to be set differently for streaming?I see two unit tests that raise this error, but I don't see any pre-existing tests showing a valid sample config for a client streaming method.
gapic-generator-python/tests/unit/samplegen/test_samplegen.py
Lines 1353 to 1402 in a8d2b3a
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 really don't remember what was going on here. My guess is that I was mildly incorrect about the actual python method signature convention and I was trying to imply that we only wanted a single request to be put into a list...?
TL;DR: It's probably a bug or at least a misreading of the spec on my part.