Skip to content

Update Zarr to v3#185

Merged
eroell merged 26 commits intomainfrom
zarr-v3
Nov 4, 2025
Merged

Update Zarr to v3#185
eroell merged 26 commits intomainfrom
zarr-v3

Conversation

@eroell
Copy link
Collaborator

@eroell eroell commented Oct 29, 2025

Closes #170.

An optional dependency (vitessce-python) is still requiring zarr<3 though, zarr v3 is an open issue vitessce/vitessce-python#481

@eroell eroell changed the title Udate Zarr to v3 Update Zarr to v3 Oct 29, 2025
@eroell eroell marked this pull request as ready for review October 29, 2025 17:43
@eroell
Copy link
Collaborator Author

eroell commented Oct 29, 2025

No blocks from our side

@eroell
Copy link
Collaborator Author

eroell commented Oct 29, 2025

@Zethson since you created the issue; was this specifically about using zarr>=3, or about removing the pins as done now?

@Zethson
Copy link
Member

Zethson commented Oct 29, 2025

zarr>=3

I think we can go with this. Don't need to support the old format

@Zethson
Copy link
Member

Zethson commented Oct 29, 2025

Hmm I had unpinned it before and ran into a test error back then. Surprised it works now but ok

@Zethson
Copy link
Member

Zethson commented Oct 29, 2025

@eroell the tests used the cached environment. This shouldn't be the case right?

@Zethson
Copy link
Member

Zethson commented Oct 29, 2025

Also, if you check the notebooks jobs:

  • zarr==2.18.7

@eroell
Copy link
Collaborator Author

eroell commented Nov 2, 2025

If vitessce is included as a documentation build dependency, the following error is raised

      File "/home/docs/.local/share/hatch/env/virtual/ehrdata/1hBfmIf-/docs/lib/python3.13/site-packages/upath/core.py", line 8, in <module>
        from pathlib import _PosixFlavour  # type: ignore
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ImportError: cannot import name '_PosixFlavour' from 'pathlib' (/home/docs/.asdf/installs/python/3.13.3/lib/python3.13/pathlib/__init__.py)

I think the new appearance of this error has to do with multiple more recent packages being used now that the zarr<3 pin is removed in favor of zarr>=3.
Within reasonable time, I could not backtrace its specific cause.

I became suspicious as well whether lamindb_setup's pin to "universal_pathlib==0.2.6" has something to do with it, but this seems to not be to blame.

Since vitessce-python relies on zarr<3, I suggest to remove this dependency from the docs build and skip intersphinx links until vitessce-python accepts zarr>=3.

@eroell eroell requested a review from flying-sheep November 2, 2025 14:18
@flying-sheep
Copy link
Contributor

flying-sheep commented Nov 3, 2025

I became suspicious as well whether lamindb_setup's pin to "universal_pathlib==0.2.6" has something to do with it, but this seems to not be to blame.

That package provides the upath import, but starting from 0.2.0, it no longer tries to import _PosixFlavour, so this traceback implies that a version of universal_pathlib other than the one pinned by lamindb was installed.


also even if you remove the vitessce dep from the docs, there is absolutely no reason to remove the link from :meth:`~vitessce.config.VitessceConfig.widget`! Intersphinx doesn’t need the package installed, just an entry in theintersphinx_mapping.

@eroell
Copy link
Collaborator Author

eroell commented Nov 3, 2025

That package provides the upath import, but fsspec/universal_pathlib#173, it no longer tries to import _PosixFlavour, so this traceback implies that a version of universal_pathlib other than the one pinned by lamindb was installed.

Indeed, I have the suspicion that along the dependency tree of vitessce a pin could exist? Since there were not actively maintained packages included too, I stopped digging at one point..

@eroell
Copy link
Collaborator Author

eroell commented Nov 3, 2025

also even if you remove the vitessce dep from the docs, there is absolutely no reason to remove the link from :meth:~vitessce.config.VitessceConfig.widget! Intersphinx doesn’t need the package installed, just an entry in theintersphinx_mapping.

OK! I'll add this again then

@flying-sheep
Copy link
Contributor

flying-sheep commented Nov 3, 2025

It’s really easy, I just added an lower bound to lamindb. Seems like uv thought it was a good idea to install some ancient lamindb version together with a universal_pathlib==0.1.0 that doesn’t support Python 3.12+

Also you let your docs degrade by not running it with -W. It was really easy to fix the breakage, just leave that flag in so you know when things break!.

  • I added scanpy and fsspec to intersphinx_mapping (thank you LLMs for correctly guessing the URLs that I could then verify by simply clicking them)
  • I added a qualnames_override for zarr.storage._common.StorePathzarr.storage.StorePath
  • I added nitpick_ignores for zarr.core.buffer.core.Buffer (which doesn’t seem to be exported) and Initial support for PEP 695 type aliases sphinx-doc/sphinx#13508
  • I fixed the broken .. figure:: path

Most of these should have been fixed when they were introduced (except for the zarr stuff, which makes sense to be fixed in this PR)

path: Path | None = None,
*,
store: Path | Store | None = None,
store: Path | StoreLike | None = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don’t know if vitessce takes a StoreLike or only a real zarr.abc.store.Store.

If the latter, than the import should be changed.

@eroell
Copy link
Collaborator Author

eroell commented Nov 3, 2025

It’s really easy, I just added a lowerupper bound to lamindb

🤯

@flying-sheep
Copy link
Contributor

flying-sheep commented Nov 3, 2025

Ah sorry, lower bound! Don’t do upper bounds, this was just a typo.

@eroell
Copy link
Collaborator Author

eroell commented Nov 3, 2025

Ah sorry, lower bound! Don’t do upper bounds, this was just a typo.

Yes I got it, the exploding head was regarding how quickly you fixed that

Copy link
Contributor

@flying-sheep flying-sheep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good except for that nasty implicit state change on import!

Let’s wait for the discussion in scverse/anndata#2193 also!

@eroell
Copy link
Collaborator Author

eroell commented Nov 4, 2025

I changed a final thing here:

  • add chunks argument to ehrdata.io.write_zarr, with
    • default “auto” (Same style as zarr.create_array); This option uses anndata.io.write_elem, and its defaults.
    • A second option “ehrdata_auto”, using a blueprint for custom chunking as suggested in the discussion on anndata.io.write_elem with an AnnData object raises error on chunk_shape when using chunks argument scverse/anndata#2193. I don’t claim this chunking is what is best for our usecases. Rather, the implementation is now embedded and available for trying, can be adapted in the future, and should act as blueprint should “auto” turn out to not be what is best for us. It'd be easier for contributors to alter this, than finding and adapting the blueprint mentioned in this discussion.

@eroell eroell merged commit b06758d into main Nov 4, 2025
13 checks passed
@eroell eroell deleted the zarr-v3 branch November 4, 2025 10:50
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.

Support zarr v3

3 participants