Skip to content

feat: support zarr 3 - #237

Open
Marius1311 wants to merge 1 commit into
lilab-bcb:mainfrom
quadbio:fix/zarr3
Open

feat: support zarr 3#237
Marius1311 wants to merge 1 commit into
lilab-bcb:mainfrom
quadbio:fix/zarr3

Conversation

@Marius1311

@Marius1311 Marius1311 commented Aug 24, 2026

Copy link
Copy Markdown

Companion to #235. Removing the pin alone is not enough — main does not run under zarr 3:

  • zarr.hierarchy no longer exists, so ZarrDataset.is_group raises.
  • zarr 3 groups dropped attribute access to members, so dataset_schema(g) raises AttributeError: 'Group' object has no attribute 'uns'. It is written that way because it also accepts a plain AnnData, hence the small AttributeGroup adapter.
  • anndata_zarr.py is a vendored copy of anndata's zarr writer from ~2021 and uses the v2 creation API throughout.

Rather than port that copy, this deletes it (250 lines) and writes through anndata.io.write_elem — what anndata itself uses, and one less encoder to keep in step by hand.

Reads still go through the caller's fsspec mapper, which zarr 3 still accepts. Writes take the path instead, since zarr creates the directories it writes into and an fsspec LocalFileSystem mapper does not; get_fs() derives the filesystem from the path scheme, so this is equivalent.

Note requirements.txt on main already says zarr==3.3.0 while pyproject.toml says zarr<3.

Best reviewed after #233 and #236, which fix reader bugs zarr 3 exposes but does not cause.

🤖 Generated with Claude Code

Removing the zarr<3 pin is not enough on its own: zarr 3 dropped attribute access
to group members, so ZarrDataset needs a small adapter, and the vendored 2021-era
copy of anndata's zarr writer uses the v2 creation API throughout.

Delete that copy (250 lines) and write through anndata.io.write_elem instead. It
is what anndata itself uses, it tracks the encoding versions the readers expect,
and it removes the duplicated encoder entirely.

Reads keep going through the caller's fsspec mapper, which zarr 3 still accepts.
Writes take the path, because zarr creates the directories it writes into and an
fsspec LocalFileSystem mapper does not.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VYsKhgGuNCFtxqFhSLGtCK
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