Skip to content

feat(zonal): pass Preconditions to AsyncAppendableObjectWriter - #1131

Open
yuxin00j wants to merge 3 commits into
fsspec:mainfrom
yuxin00j:zonal-write-preconditions
Open

yuxin00j wants to merge 3 commits into
fsspec:mainfrom
yuxin00j:zonal-write-preconditions

Conversation

@yuxin00j

@yuxin00j yuxin00j commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #1102. googleapis/google-cloud-python#18641 (merged) exposes write preconditions on AsyncAppendableObjectWriter as preconditions=Preconditions(...); the if_generation_match= keyword that init_aaow passes today never shipped. This passes Preconditions(if_generation_match=N) instead, so zonal compare-and-swap writes work once that change is in a google-cloud-storage release. Older releases keep the current behavior: if_generation_match > 0 on zonal buckets raises NotImplementedError.

Changes

  • gcsfs/zb_hns_utils.py:
    • Import Preconditions from google.cloud.storage.asyncio.async_appendable_object_writer, falling back to None on older releases.
    • Keep mapping if_generation_match == 0 to generation=0 so exclusive create works with every google-cloud-storage version.
    • For if_generation_match > 0, raise NotImplementedError when Preconditions is unavailable and pass preconditions=Preconditions(if_generation_match=...) otherwise.
  • gcsfs/tests/test_zb_hns_utils.py, gcsfs/tests/test_core.py: update the init_aaow tests and the zonal CAS skip message.

Test plan

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the init_aaow function in gcsfs/zb_hns_utils.py to use the Preconditions class from the google-cloud-storage SDK for handling if_generation_match preconditions, rather than passing it directly as a keyword argument to AsyncAppendableObjectWriter. The unit tests have been updated to mock the Preconditions class and cover cases where the SDK does or does not support it. I have no feedback to provide as there are no review comments.

@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.24%. Comparing base (c783299) to head (9d517c1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1131   +/-   ##
=======================================
  Coverage   92.24%   92.24%           
=======================================
  Files          20       20           
  Lines        4047     4048    +1     
=======================================
+ Hits         3733     3734    +1     
  Misses        314      314           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Also rewords the comment on the generation check and drops a test for the removed TypeError fallback.
@yuxin00j
yuxin00j marked this pull request as ready for review November 3, 2026 07:49

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant