Use atomic writes for new files in LocalStore#3412
Merged
d-v-b merged 6 commits intozarr-developers:mainfrom Aug 28, 2025
Merged
Use atomic writes for new files in LocalStore#3412d-v-b merged 6 commits intozarr-developers:mainfrom
d-v-b merged 6 commits intozarr-developers:mainfrom
Conversation
Fixes zarr-developers#3411 I use the standard strategy of writing to a temporary file in the same directory, and then renaming it to the desired name. This ensure that Zarr writes are either complete or not written at all.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3412 +/- ##
==========================================
- Coverage 94.70% 94.70% -0.01%
==========================================
Files 79 79
Lines 9532 9549 +17
==========================================
+ Hits 9027 9043 +16
- Misses 505 506 +1
🚀 New features to boost your workflow:
|
d-v-b
reviewed
Aug 28, 2025
| ) -> int | None: | ||
| path.parent.mkdir(parents=True, exist_ok=True) | ||
| # write takes any object supporting the buffer protocol | ||
| view = value.as_buffer_like() |
Contributor
There was a problem hiding this comment.
this makes me wonder why Buffer doesn't implement the buffer protocol!
d-v-b
approved these changes
Aug 28, 2025
Contributor
d-v-b
left a comment
There was a problem hiding this comment.
we should probably get a release note for this change. I'm happy to write one if that works. Otherwise it looks g2g!
d-v-b
approved these changes
Aug 28, 2025
Contributor
Author
|
The missing code coverage is for the unused/untested |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #3411
I use the standard strategy of writing to a temporary file in the same directory, and then renaming it to the desired name. This ensure that Zarr writes are either complete or not written at all.
It would be nice if partial writes (
_put()withstart) could also be atomic, but I'm honestly not sure if both atomic and efficient partial writes of files are possible. Interestingly, I don't see any uses ofset_partial_values()inside Zarr, so maybe this feature isn't needed after all? (see #2859 for discussion)TODO:
changes/