Skip to content

feat: ZipStore accepts open binary file-like objects - #4187

Open
jhamman wants to merge 1 commit into
zarr-developers:mainfrom
jhamman:feature/zipstore-file-like
Open

feat: ZipStore accepts open binary file-like objects#4187
jhamman wants to merge 1 commit into
zarr-developers:mainfrom
jhamman:feature/zipstore-file-like

Conversation

@jhamman

@jhamman jhamman commented Jul 26, 2026

Copy link
Copy Markdown
Member

Summary

Allows constructing a ZipStore from any seekable binary reader, enabling zip archives on remote storage:

  • io objects (BytesIO, fsspec file objects) are used directly
  • minimal readers that are not io.IOBase instances and whose read() may return buffer-protocol objects rather than bytes (e.g. obstore.ReadableFile) are adapted via a small io.RawIOBase wrapper when opened for reading

clear()/move() raise NotImplementedError for file-object-backed stores.

For reviewers

This is the first of a series of Pull Requests toward #2943.

Author attestation

  • I am a human, these are my changes, and I have reviewed and understood every change and can explain why each is correct.

TODO

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/user-guide/*.md
  • Changes documented as a new file in changes/
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

@jhamman
jhamman force-pushed the feature/zipstore-file-like branch from e980c52 to ebc18e5 Compare July 26, 2026 04:22
@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.87%. Comparing base (eefa424) to head (b5f99fb).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4187      +/-   ##
==========================================
+ Coverage   93.84%   93.87%   +0.02%     
==========================================
  Files          91       91              
  Lines       12549    12594      +45     
==========================================
+ Hits        11777    11822      +45     
  Misses        772      772              
Files with missing lines Coverage Δ
src/zarr/storage/_zip.py 98.18% <100.00%> (+0.46%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jhamman
jhamman force-pushed the feature/zipstore-file-like branch from ebc18e5 to dc84c55 Compare July 26, 2026 04:59
Comment thread src/zarr/storage/_zip.py Outdated
@jhamman
jhamman force-pushed the feature/zipstore-file-like branch 2 times, most recently from 896d25b to 7d33da8 Compare July 26, 2026 13:36
@jhamman
jhamman requested a review from d-v-b July 26, 2026 13:59
Comment thread tests/test_store/test_zip.py
Comment thread tests/test_store/test_zip.py
Comment thread tests/test_store/test_zip.py Outdated
@jhamman
jhamman force-pushed the feature/zipstore-file-like branch from 7d33da8 to ef00953 Compare July 27, 2026 15:12
Allows constructing a ZipStore from any seekable binary reader, enabling
zip archives on remote storage:

- io objects (BytesIO, fsspec file objects) are used directly
- minimal readers that are not io.IOBase instances and whose read() may
  return buffer-protocol objects rather than bytes (e.g.
  obstore.ReadableFile) are adapted via a small io.RawIOBase wrapper
  when opened for reading

clear()/move() raise NotImplementedError for file-object-backed stores.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jhamman
jhamman force-pushed the feature/zipstore-file-like branch from 54fa1dd to b5f99fb Compare July 27, 2026 19:14
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.

2 participants