-
-
Notifications
You must be signed in to change notification settings - Fork 364
Use atomic writes for new files in LocalStore #3412
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
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:
|
) -> int | None: | ||
path.parent.mkdir(parents=True, exist_ok=True) | ||
# write takes any object supporting the buffer protocol | ||
view = value.as_buffer_like() |
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 makes me wonder why Buffer
doesn't implement the buffer protocol!
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.
we should probably get a release note for this change. I'm happy to write one if that works. Otherwise it looks g2g!
The missing code coverage is for the unused/untested |
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/