Skip to content

Commit

Permalink
(fix): upper bound zarr at runtime (and in docs + benchmark) (#1819)
Browse files Browse the repository at this point in the history
* (fix): upper bound zarr at runtime

* (chore): improve message

* (fix): asv benchmarking config

* (chore): fix docs

* (fix): intersphinx mapping

* (chore): release note

* simpler version

* (refactor): `ImportError` instead of `RuntimeError`

---------

Co-authored-by: Philipp A. <[email protected]>
  • Loading branch information
ilan-gold and flying-sheep authored Jan 10, 2025
1 parent a8c62e8 commit 1bf63a0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion benchmarks/asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"natsort": [""],
"pandas": [""],
"memory_profiler": [""],
"zarr": [""],
"zarr": ["2.18.4"],
"pytoml": [""],
"pytest": [""],
"pooch": [""],
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def setup(app: Sphinx):
python=("https://docs.python.org/3", None),
scipy=("https://docs.scipy.org/doc/scipy", None),
sklearn=("https://scikit-learn.org/stable", None),
zarr=("https://zarr.readthedocs.io/en/stable", None),
zarr=("https://zarr.readthedocs.io/en/v2.18.4/", None),
xarray=("https://docs.xarray.dev/en/stable", None),
dask=("https://docs.dask.org/en/stable", None),
)
Expand Down
1 change: 1 addition & 0 deletions docs/release-notes/1819.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upper bound `zarr` at runtime {user}`ilan-gold`
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ doc = [
"sphinxext.opengraph",
"nbsphinx",
"scanpydoc[theme,typehints] >=0.14.1",
"zarr",
"zarr<3",
"awkward>=2.3",
"IPython", # For syntax highlighting in notebooks
"myst_parser",
Expand All @@ -88,7 +88,7 @@ test = [
"loompy>=3.0.5",
"pytest>=8.2,<8.3.4",
"pytest-cov>=2.10",
"zarr<3.0.0a0",
"zarr<3",
"matplotlib",
"scikit-learn",
"openpyxl",
Expand Down
5 changes: 5 additions & 0 deletions src/anndata/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ def __exit__(self, *_exc_info) -> None:
#############################

if find_spec("zarr") or TYPE_CHECKING:
import zarr

if Version(zarr.__version__).major > 2:
raise ImportError("zarr-python major version > 2 is not supported")

from zarr.core import Array as ZarrArray
from zarr.hierarchy import Group as ZarrGroup
else:
Expand Down

0 comments on commit 1bf63a0

Please sign in to comment.