zarr-python icon indicating copy to clipboard operation
zarr-python copied to clipboard

fix: ensure `ZipStore` is open before acquiring lock

Open oelhammouchi opened this issue 1 month ago • 5 comments

Fix a bug where ZipStore complains that it has no attribute _lock when some methods are called. Any method using the lock should make sure the store is opened because that's when the _lock attribute gets set.

oelhammouchi avatar Nov 21 '25 00:11 oelhammouchi

Codecov Report

:x: Patch coverage is 50.00000% with 6 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 59.14%. Comparing base (e456b09) to head (2aa6e14). :warning: Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/zarr/storage/_zip.py 50.00% 6 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3593      +/-   ##
==========================================
- Coverage   59.15%   59.14%   -0.02%     
==========================================
  Files          86       86              
  Lines       10170    10182      +12     
==========================================
+ Hits         6016     6022       +6     
- Misses       4154     4160       +6     
Files with missing lines Coverage Δ
src/zarr/storage/_zip.py 70.39% <50.00%> (-1.47%) :arrow_down:
:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Nov 21 '25 00:11 codecov[bot]

how did the bug you are fixing here get past the store tests? Maybe we need to make those tests stronger?

d-v-b avatar Nov 21 '25 16:11 d-v-b

You're right, I didn't want to appear presumptuous but the code could do with some refactoring as well, having to repeat all those _sync_open calls in so many functions naturally increases the probability of forgetting some. Not sure if this should be done in this PR though.

oelhammouchi avatar Nov 22 '25 12:11 oelhammouchi

if you can find a clean way to reduce the repetition (e.g., a decorator) we'd appreciate it!

d-v-b avatar Nov 22 '25 13:11 d-v-b

@d-v-b just for info, I'm currently on holiday but I'm planning to implement the proposed improvements shortly

oelhammouchi avatar Nov 29 '25 06:11 oelhammouchi