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 `AppendRowsStream` helper to append rows with a `BigQueryWriteClient` by tswast · Pull Request #284 · googleapis/python-bigquery-storage

This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Conversation

@tswast

@tswast tswast commented Aug 26, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Follow-up to #278

TODO:

  • Fail fast with bad initial request (add close callback?)
  • System test for bad initial request
  • Unit test for timeout behavior
  • Unit/system test that checks that RPC is actually open after open
  • How long does it take for the RPC to open? (on my laptop: between 0.25 and 0.4 seconds) Add some sleep calls to busy loop?

Closes #285

Sorry, something went wrong.

Uh oh!

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

All reactions
tswast added 23 commits August 9, 2021 16:38
@tswast
WIP: write client sample
c34e0bf
@tswast
add sample with nullable types
c9d6338
@tswast
add schema for all supported types
dbe2a21
@tswast
add complex types to code sample
e5b7b3f
@tswast
refactor sample so that it can be tested
2d927b1
@tswast
make test assertions more thorough
19b746e
@tswast
Merge branch 'master' into b195450856-write-client
f6af466
@tswast
fix lint error
483b0e3
@tswast
Merge remote-tracking branch 'origin/b195450856-write-client' into b1…
a74e7ea
…95450856-write-client
@tswast
remove done TODO
eba8539
@tswast
address reviewer comments
40e2800
@tswast
fix tag mismatch
49c3c58
@tswast
test on multiple regions
6d30337
@tswast
Merge remote-tracking branch 'upstream/master' into b195450856-write-…
cc969eb
…client
@tswast
correct comments about why offset exists
bba6df4
@tswast
upgrade g-c-b
dcc648d
@tswast
WIP: invert stream using BiDi class
12a82a1
@tswast
WIP: attempt to use Future for send instead
1beb0b9
@tswast
WIP: use futures, populated by background consumer
34e5cbd
@tswast
make sure stream is actually open before returning from open
d2491b1
@tswast
copy close implementation from pub/sub
daf42a8
@tswast
support extra metadata
c40b51f
@tswast
Merge remote-tracking branch 'upstream/master' into b195450856-write-…
8bcc36c
…client-BiDi
@product-auto-label product-auto-label Bot added the api: bigquerystorage Issues related to the googleapis/python-bigquery-storage API. label Aug 26, 2021
@snippet-bot

snippet-bot Bot commented Aug 26, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 2 region tags.
  • samples/snippets/append_rows_proto2.py:15, tag bigquerystorage_append_rows_raw_proto2
  • samples/snippets/sample_data.proto:15, tag bigquerystorage_append_rows_raw_proto2_definition

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.

@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Aug 26, 2021
tswast added 2 commits August 26, 2021 13:36
@tswast
process exceptions, add open timeout
350628d
@tswast
sort imports
4086445
@tswast
tswast marked this pull request as ready for review August 26, 2021 20:23
@tswast
tswast requested a review from a team August 26, 2021 20:23
@tswast
add sleep to loop waiting for RPC to be active
faaee9e
@tswast

tswast commented Aug 31, 2021

Copy link
Copy Markdown
Contributor Author

Uh oh. The BackgroundConsumer eats errors if I send an invalid stream name: https://github.com/googleapis/python-api-core/blob/dcb6ebd9994fddcb1729150df1675ebf8c503a73/google/api_core/bidi.py#L659-L667

It doesn't even send a "done" notification... Hmmm...

All reactions

Sorry, something went wrong.

Uh oh!

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

@tswast tswast mentioned this pull request Aug 31, 2021
bidi.BackgroundConsumer.start() eats exception when _bidi_rpc.open() fails googleapis/python-api-core#268
Closed
tswast added 4 commits August 31, 2021 16:18
@tswast
don't freeze if initial RPC fails
46dd60e
@tswast
Merge remote-tracking branch 'upstream/main' into b195450856-write-cl…
4563e4b
…ient-BiDi
@tswast
add needed initializations so done() functions
22b7b0c
@tswast
fail fast when there is a problem with the initial request
e307c8f
@tswast

tswast commented Sep 3, 2021

Copy link
Copy Markdown
Contributor Author

Samples tests are timing out, stuck waiting for the futures to be done. Possible I messed something up when making the done() call work when called directly.

All reactions

Sorry, something went wrong.

Uh oh!

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

tswast added 3 commits September 3, 2021 16:55
@tswast
don't inherit concurrent.futures
2b26b3d
It's unnecessary and kept resulting in stuff getting stuck.
@tswast
Merge remote-tracking branch 'upstream/main' into b195450856-write-cl…
0e91a6a
…ient-BiDi
@tswast
add unit test for open timeout
a3185e9
@tswast tswast added owlbot:run Add this label to trigger the Owlbot post processor. and removed do not merge Indicates a pull request not ready for merge, due to either quality or timing. labels Sep 8, 2021
@gcf-owl-bot
🦉 Updates from OwlBot
61fa79f
See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 8, 2021
tswast added 2 commits September 8, 2021 16:34
@tswast
add manual client to docs
6fc1c75
@tswast
Merge remote-tracking branch 'origin/b195450856-write-client-BiDi' in…
7bddd4f
…to b195450856-write-client-BiDi
@tswast tswast changed the title feat: add BigQueryWriteClient where append_rows returns a helper for writing row feat: add BigQueryWriteClient where append_rows returns a helper for writing rows Sep 8, 2021
shollyman
shollyman reviewed Sep 8, 2021
View reviewed changes
Comment thread google/cloud/bigquery_storage_v1beta2/client.py Outdated
def append_rows(
self,
initial_request: types.AppendRowsRequest,
# TODO: add retry argument. Blocked by

@shollyman shollyman Sep 8, 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.

if you want to keep arg order stable, should you stub something here?

Sorry, something went wrong.

Uh oh!

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

All reactions

@tswast tswast Sep 9, 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.

Good point. I've added a * to force timeout and metadata to be keyword arguments only. This is the approach the generated clients have been taking to avoid argument order being a part of the contract.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread google/cloud/bigquery_storage_v1beta2/client.py Outdated
metadata.

Returns:
A tuple containing a stream and a future. Use the stream to send

@shollyman shollyman Sep 8, 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.

This contract feels odd to me at first blush. You seem to have two different ways of appending, depending on whether it's the first append (client append_rows) or a subsequent append(send on the returned stream). I expect this to get odd with retries.

Alternatively, perhaps you just have an open_stream method or similar in the write client, which can be opened with the necessary requisite data (stream id, schema, etc), and the caller doesn't have to be responsible for dealing with the special logic for the first append?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread google/cloud/bigquery_storage_v1beta2/writer.py
self.__cancelled = False
self._is_done = False

def cancel(self):

@shollyman shollyman Sep 8, 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.

cancel() on an individual future kills all the futures on the same manager? This feels like something that maybe should live on a connection abstraction. Or will it be impossible for python to end up in the state where you have one stream that's draining and one that's accepting new appends?

Sorry, something went wrong.

Uh oh!

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

All reactions

@tswast tswast Sep 9, 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.

It does seem odd to cancel everything sent later, though that's the semantics I copied from Pub/Sub. From what I can tell, _reopen isn't called until the old RPC has completely shut down.

https://github.com/googleapis/python-api-core/blob/8b65c93aef908c99784200b73ad270a0591481a8/google/api_core/bidi.py#L444-L451

Now that I look more closely, stream resumption only allows one request for the "initial request".

https://github.com/googleapis/python-api-core/blob/8b65c93aef908c99784200b73ad270a0591481a8/google/api_core/bidi.py#L101-L105

That'll probably have to be refactored if/when we do stream resumption so that we can re-send any requests where we didn't get a response yet.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread samples/snippets/append_rows_proto2.py Outdated
proto_data.rows = proto_rows

# Generate a protocol buffer representation of your message descriptor. You
# must inlcude this information in the first request of an append_rows

@shollyman shollyman Sep 8, 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.

s/inlcude/include/

Sorry, something went wrong.

Uh oh!

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

All reactions
tswast added 5 commits September 9, 2021 11:58
@tswast
typo in sample comments
0c5d08c
@tswast
force timeout and metadata to be kwargs
dc33c88
@tswast
unify interface for sending row data
9b229a3
@tswast
pull stream name from merged request
001a922
@tswast
require newer proto-plus for copy_from method
68507d8
@tswast
tswast requested a review from shollyman September 10, 2021 14:39
shollyman
shollyman approved these changes Sep 10, 2021
View reviewed changes

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

This seems much more aligned as a connection pattern, thanks for all the work getting it into shape!

Sorry, something went wrong.

Uh oh!

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

tswast reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@tswast
tswast merged commit 2461f63 into googleapis:main Sep 10, 2021
@tswast
tswast deleted the b195450856-write-client-BiDi branch September 10, 2021 22:07
@tswast tswast changed the title feat: add BigQueryWriteClient where append_rows returns a helper for writing rows feat: add AppendRowsStream helper to append rows with a BigQueryWriteClient Sep 10, 2021
gcf-merge-on-green Bot pushed a commit that referenced this pull request Sep 13, 2021
@release-please
chore: release 2.8.0 (#297)
eb74af9
🤖 I have created a release \*beep\* \*boop\*
---
## [2.8.0](https://www.github.com/googleapis/python-bigquery-storage/compare/v2.7.0...v2.8.0) (2021-09-10)


### Features

* add `BigQueryWriteClient` where `append_rows` returns a helper for writing rows ([#284](https://www.github.com/googleapis/python-bigquery-storage/issues/284)) ([2461f63](https://www.github.com/googleapis/python-bigquery-storage/commit/2461f63d37f707c2d634a95d87b8ffc3e4af3686))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@dandhlee dandhlee Awaiting requested review from dandhlee
1 more reviewer
@shollyman shollyman shollyman 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

api: bigquerystorage Issues related to the googleapis/python-bigquery-storage API. 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.

2 participants

@tswast @shollyman
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.