-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix #351: batch updates via context manager #352
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 #351: batch updates via context manager #352
Conversation
They are opinionated, and not usefully so for our use cases: - Data mapping objects have methods based on schema, not an a priori thumb rule. - Context managers may have *no* public methods.
- Defers / aggregates repeated calls to '_patch_properties' within the scope of a 'with foo.batch:' block. - Issues a single '_patch_properties' call with the aggregated dict, IFF the block exits without an exception.
E.g., to batch multiple updates:: | ||
|
||
>>> with instance.batch: | ||
... instance._patch_properties({'foo': 'Foo'}) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This is great! LGTM except for the Travis lint failure. Ping me after fixing so I can do a final pass. |
The Travis failure is actually a bug in the "optimize lint" code: because not all files are considered, the 'abstract-class-not-used' warning kicks in. I can "fix" the failure by checking in a spurious change to |
Aha! That seems like the easiest get-out-of-jail free card for this PR. Any ideas for how to fix this going forward? (I know its my hack, but no good ideas come to mind quickly.) Seems unlikely enough that maybe we just don't waste engineering effort on trying to fix this corner case? |
I'd be tempted to just disable the pylint |
They are helpful in finding dead code. IMO, the more "out-of-the-box" our usage of |
@tseaver Green Travis, feel free to merge. |
Changes Unknown when pulling 245b0e9 on tseaver:351-batch_updates_via_context_manager into * on GoogleCloudPlatform:master*. |
I find it over-opinionated, myself. |
…nager Fix #351: batch updates via context manager
Source-Link: googleapis/synthtool@1b9ad76 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:9db98b055a7f8bd82351238ccaacfd3cda58cdf73012ab58b8da146368330021
* docs: Fix formatting of request arg in docstring chore: Update gapic-generator-python to v1.9.1 PiperOrigin-RevId: 518604533 Source-Link: googleapis/googleapis@8a085ae Source-Link: googleapis/googleapis-gen@b2ab4b0 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjJhYjRiMGEwYWUyOTA3ZTgxMmMyMDkxOThhNzRlMDg5OGFmY2IwNCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
…352) Source-Link: googleapis/synthtool@95d9289 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:c8878270182edaab99f2927969d4f700c3af265accd472c3425deedff2b7fd93 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
* docs: mention that some fields are deprecated PiperOrigin-RevId: 519755058 Source-Link: googleapis/googleapis@26b4d27 Source-Link: googleapis/googleapis-gen@7ad7fcf Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiN2FkN2ZjZjllNWQyYThiMjQzOTM1ZWMyMDk1NGZiMjkwMTg1ODkxNSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Source-Link: googleapis/synthtool@5f2a608 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:8555f0e37e6261408f792bfd6635102d2da5ad73f8f09bcb24f25e6afb5fac97 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* chore(python): add support for python 3.11 Source-Link: googleapis/synthtool@7197a00 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:c43f1d918bcf817d337aa29ff833439494a158a0831508fda4ec75dc4c0d0320 * trigger CI Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
* chore: use gapic-generator-python 0.65.2 PiperOrigin-RevId: 444333013 Source-Link: googleapis/googleapis@f91b6cf Source-Link: googleapis/googleapis-gen@16eb360 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTZlYjM2MDk1YzI5NGU3MTJjNzRhMWJmMjM1NTA4MTdiNDIxNzRlNSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
Co-authored-by: Anthonios Partheniou <[email protected]>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
See #351.
Add 'batch' property to '_PropertyMixin'.
with
block, all changes are discarded.E.g:
results in a single
PATCH
request, with payload: