Skip to content

Conversation

@tseaver
Copy link
Contributor

@tseaver tseaver commented Nov 7, 2014

See #351.

Add 'batch' property to '_PropertyMixin'.

  • 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.
  • If an exception is raised from the with block, all changes are discarded.

E.g:

with key.batch:
    key.content_type = 'image/jpeg'
    key.content_disposition = 'attachment; filename="photo.jpg"'

results in a single PATCH request, with payload:

{'contentType': 'image/jpeg', 'contentDisposition': 'attachment; filename="photo.jpg"'}

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.
@tseaver tseaver added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. api: storage Issues related to the Cloud Storage API. labels Nov 7, 2014

This comment was marked as spam.

@dhermes
Copy link
Contributor

dhermes commented Nov 7, 2014

This is great!

LGTM except for the Travis lint failure.

Ping me after fixing so I can do a final pass.

@tseaver
Copy link
Contributor Author

tseaver commented Nov 7, 2014

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 bucket.py or key.py.

@dhermes
Copy link
Contributor

dhermes commented Nov 7, 2014

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?

@tseaver
Copy link
Contributor Author

tseaver commented Nov 7, 2014

I'd be tempted to just disable the pylint abstract-class-not-used and abstract-class-little-used checks, myself.

@dhermes
Copy link
Contributor

dhermes commented Nov 7, 2014

They are helpful in finding dead code. IMO, the more "out-of-the-box" our usage of pylint the better.

@dhermes
Copy link
Contributor

dhermes commented Nov 7, 2014

@tseaver Green Travis, feel free to merge.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 245b0e9 on tseaver:351-batch_updates_via_context_manager into * on GoogleCloudPlatform:master*.

@tseaver
Copy link
Contributor Author

tseaver commented Nov 7, 2014

I find it over-opinionated, myself.

tseaver added a commit that referenced this pull request Nov 7, 2014
…nager

Fix #351: batch updates via context manager
@tseaver tseaver merged commit 8536991 into googleapis:master Nov 7, 2014
@tseaver tseaver deleted the 351-batch_updates_via_context_manager branch November 7, 2014 01:27
parthea pushed a commit that referenced this pull request Jun 4, 2023
Source-Link: googleapis/synthtool@1b9ad76
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:9db98b055a7f8bd82351238ccaacfd3cda58cdf73012ab58b8da146368330021
parthea pushed a commit that referenced this pull request Jun 4, 2023
* 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>
parthea pushed a commit that referenced this pull request Jun 4, 2023
…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>
parthea added a commit that referenced this pull request Jul 6, 2023
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
parthea pushed a commit that referenced this pull request Sep 22, 2023
* 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>
parthea added a commit that referenced this pull request Sep 22, 2023
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 <partheniou@google.com>
parthea pushed a commit that referenced this pull request Sep 22, 2023
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea added a commit that referenced this pull request Sep 22, 2023
* 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 <partheniou@google.com>
parthea pushed a commit that referenced this pull request Sep 22, 2023
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea added a commit that referenced this pull request Oct 21, 2023
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
parthea pushed a commit that referenced this pull request Oct 21, 2023
parthea pushed a commit that referenced this pull request Oct 21, 2023
parthea added a commit that referenced this pull request Oct 21, 2023
* 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 <partheniou@google.com>
parthea added a commit that referenced this pull request Oct 21, 2023
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
parthea pushed a commit that referenced this pull request Oct 21, 2023
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Aug 21, 2025
parthea pushed a commit that referenced this pull request Sep 16, 2025
parthea pushed a commit that referenced this pull request Nov 22, 2025
parthea pushed a commit that referenced this pull request Nov 24, 2025
parthea pushed a commit that referenced this pull request Nov 24, 2025
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Nov 24, 2025
Source-Link: googleapis/synthtool@6702a34
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:fbbc8db67afd8b7d71bf694c5081a32da0c528eba166fbcffb3b6e56ddf907d5

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Chalmer Lowe <chalmerlowe@google.com>
parthea pushed a commit that referenced this pull request Nov 24, 2025
* chore(deps): update all dependencies

* 🦉 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>
parthea added a commit that referenced this pull request Nov 24, 2025
This PR migrates from autosynth to [owl bot](https://github.com/googleapis/repo-automation-bots/tree/master/packages/owl-bot).  owl bot will save time for maintainers as it will automatically open PRs when there are updates in [googleapis-gen](https://github.com/googleapis/googleapis-gen/tree/master/google) without requiring maintainers to run `synthtool` to build the client from protos. Additionally, similar to autosynth, PRs will be automatically opened when there are template updates.
parthea added a commit that referenced this pull request Nov 24, 2025
There is [an issue](https://github.com/googleapis/python-firestore/blob/master/owlbot.py#L60) in the `owlbot.py` file added in #352 in that [s.remove_staging_dirs()](https://github.com/googleapis/synthtool/blob/master/synthtool/transforms.py#L309) should only be called once after all the files are copied over.  [get_staging_dirs()](https://github.com/googleapis/synthtool/blob/master/synthtool/transforms.py#L280) will only return staging directories that exist.
parthea pushed a commit that referenced this pull request Nov 24, 2025
Source-Link: googleapis/synthtool@53ea389
Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:e1793a23ae0ee9aafb2e3a53b564a351f74790dbe3c2d75f8fc3b8c43e5c036c
parthea pushed a commit that referenced this pull request Nov 24, 2025
* updated CHANGELOG.md [ci skip]

* updated setup.py [ci skip]
parthea pushed a commit that referenced this pull request Nov 25, 2025
Source-Link: googleapis/synthtool@53ea389
Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:e1793a23ae0ee9aafb2e3a53b564a351f74790dbe3c2d75f8fc3b8c43e5c036c
parthea pushed a commit that referenced this pull request Nov 26, 2025
This should make this library more robust in case of breaking changes in one of
its dependencies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants