Skip to content

feat(zarr-storage): add the zarr-storage package with zarr's store code in zarr_storage.legacy - #490

Open
d-v-b wants to merge 12 commits into
mainfrom
feat/zarr-storage-legacy
Open

d-v-b wants to merge 12 commits into
mainfrom
feat/zarr-storage-legacy

Conversation

@d-v-b

@d-v-b d-v-b commented Dec 3, 2026

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

Add zarr-storage, a package for zarr-python's storage code. zarr_storage.legacy holds the store interface of zarr-python 3 and its stores, without a dependency on zarr; zarr will depend on it. Until then it is a copy of the code in zarr, kept identical by a script.

This is steps 1 and 2 of zarr-developers#4682, and the first half of the split of #488. The second half, the new store API in zarr_storage.experimental, is stacked on this PR. Merge this one first. It does what zarr-developers#4318 does, but without importing zarr, which step 3 (zarr depends on this package) needs.

Maintainer setup needed before the first release, as for the other sub-packages:

  • a zarr-storage GitHub label (the labeler applies it);
  • a Read the Docs subproject zarr-storage whose configuration file is packages/zarr-storage/.readthedocs.yaml;
  • PyPI and TestPyPI trusted publishers for zarr-storage-release.yml, with environments zarr-storage-releases and zarr-storage-releases-test.
What is in zarr_storage.legacy
  • The module zarr.X is zarr_storage.legacy.X. Copied whole, apart from imports and documentation links: abc/{buffer,store,url_pipeline}, storage/*, experimental/cache_store, buffer/*, core/{_coalesce,_json,sync}, core/buffer/*, errors, testing/{buffer,store,utils}.
  • Copied in part, because the rest serves arrays and codecs: core/common, core/config (the keys async, threading, buffer, ndbuffer), registry (buffers and URL adapters), codecs/bytes (EndianLiteral), testing/strategies (keys and key ranges) and testing/stateful (ZarrStoreStateMachine).
  • zarr_storage.legacy exports the public names of zarr.abc.store and zarr.storage.
  • Dependencies, with zarr's floors: numpy, donfig, packaging. Python 3.12 and later, as zarr.
  • A pytest plugin registers the gpu marker that the conformance suite uses, as zarr's does, without importing the stores.
  • Until zarr depends on the package, its classes are separate from zarr's: zarr doesn't accept its stores, and plugins written for zarr's entry points don't work with it. The README says so.
Keeping the copy identical

packages/zarr-storage/scripts/sync_legacy.py writes the copy from src/zarr (just zarr-storage sync-legacy), and the legacy in sync with zarr CI job runs it with --check when src/zarr or the package changes. It fails on a difference in any file, on a new import of a zarr module that isn't copied, on a read of a configuration key the copy lacks, and on a change to the two pieces of zarr code that the script has its own version of. So a store fix is made once, in src/zarr. The script goes away with step 3.

Testing
  • The store tests of zarr, ported, without those that create arrays or groups: 3397 pass on macOS (Python 3.12), against mock S3 as well.
  • Step 3, simulated in a throwaway copy of the repository before the review fixes: with zarr's store modules replaced by re-exports of this package, 14,426 of zarr's own tests passed and none failed. The 26 collection errors were pytest's doctest collector refusing aliased module files. The review repeated it on a subset (4670 passed). The review fixes didn't change the copied store modules.
  • mypy strict, ruff and mkdocs build --strict are clean. The sdist's tests passed unpacked, before the review fixes.
Review record

The agent ran adversarial reviews with fresh reviewer agents, and confirmed findings before fixing them.

Round 1 found no behavior difference in the copied code. Fixed:

  • the drift check missed changes behind the script's hand-written parts;
  • the pytest plugin was missing;
  • ZarrStoreStateMachine was missing;
  • the script depended on the working directory, and left stale files behind;
  • repeated definitions (overloads) would have been dropped;
  • several store-only paths had no test here;
  • the release smoke test didn't import legacy.

Not fixed: no CI job runs the declared dependency floors (the reviewer ran the suite on them: 3281 passed, without the S3 tests).

Round 2 (the fixes). Serious, fixed: warning filters applied per test made some subsets fail when the garbage collector ran late; they are session-wide again, as in the root configuration. Minor, fixed: extracted definitions skipped the import check, relative imports weren't rejected, a new argument to zarr's Config(...) was ignored, and one test missed its branch. Not fixed: the configuration-key check only sees a variable named config.

Round 3 (the fixes of round 2): see the comment below.

🤖 Generated with Claude Code

d-v-b and others added 2 commits December 3, 2026 13:32
…de in zarr_storage.legacy

Steps 1 and 2 of zarr-developers#4682. `zarr_storage.legacy` holds
the store interface of zarr-python 3, its stores, the conformance suite and
state machine for stores, and what they build on (buffers, the buffer and URL
adapter registries, the configuration keys they read, errors), without
importing zarr, so zarr can depend on it. The module `zarr.X` is
`zarr_storage.legacy.X`.

`scripts/sync_legacy.py` writes the copy from `src/zarr`, and CI checks that
the two match, so a store fix is made once until zarr re-exports this code.
No zarr runtime code changes.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…3.14

Python 3.14 reports a leaked event loop or socket as "Exception ignored
while ..." where earlier versions say "in", so the session's filters missed
them there.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@d-v-b

d-v-b commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

🤖 AI text below 🤖

Review rounds 3 and 4, which the description refers to.

  • Round 3 (the fixes of round 2): nothing serious. Minor, fixed in a40c5e2: the session's warning filters didn't match Python 3.14's wording for leaked event loops and sockets. Minor, documented in pyproject.toml: the filters also hide such leaks in the other tests of this package. Minor, not fixed, with no instance today: a docstring example that imports a zarr module outside the copy would be rewritten to a module that doesn't exist.
  • Round 4 (a40c5e2 and the fragment's number): nothing serious, so review stopped after two clean rounds. The reviewer ran the suite on Python 3.12, 3.13, 3.14 and free-threaded 3.14: 3397 passed on each. Minor: the fragment has this fork PR's number, and must get the upstream PR's number when this goes upstream. Minor, already there in the root configuration these filters are copied from: the patterns also search the traceback, so an unrelated error whose traceback mentions those names would be hidden. The root pyproject.toml has the same Python 3.14 gap, which this PR doesn't change.

@d-v-b
d-v-b marked this pull request as ready for review December 3, 2026 12:47
d-v-b and others added 4 commits December 3, 2026 15:11
The filter for s3fs sessions that were never entered also hid every error in
a weakref callback run by the garbage collector on Python 3.14 (except the
free-threaded build). It now requires "Session was never entered" in all
cases.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The three modules logged under `__name__`. `zarr_storage.legacy` holds copies of them, and will be
where the code lives, so their records would leave the `zarr` logger and its settings.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@d-v-b

d-v-b commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

🤖 AI text below 🤖

Review record for cfe2d4bb0..6f6f509d7 (logger names, Python 3.15, docs pins). The agent ran two rounds with fresh reviewers. Neither found anything serious in these changes.

  • Round 1, minor: the logger comment referred to itself in the legacy copy. Fixed in 6f6f509d7.
  • Round 1, not live in this PR: once the root and this package share a uv workspace, the CI matrix would run Python 3.12 in every job, and some root lockfile pins don't support 3.15. Both are recorded for the PR that adds the workspace.
  • Round 2, minor, not changed: the docs recipes print a MkDocs 2 banner, as the sibling packages' do.

d-v-b and others added 5 commits December 4, 2026 16:01
…gacy copy

zarr-developers#4696 changed `zarr.experimental.cache_store`, so the legacy copy and the
"legacy in sync with zarr" check fell behind. Regenerated, with that PR's store-level tests added
to the copy of the test module.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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