Skip to content

Commit 750a439

Browse files
committed
Merge branch 'main' of github.com:zarr-developers/zarr-python into feat/read-funcs
2 parents 4b45ebf + 1a75957 commit 750a439

28 files changed

+888
-550
lines changed

.github/workflows/test.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,22 @@ jobs:
9393
- name: Run Tests
9494
run: |
9595
hatch env run --env ${{ matrix.dependency-set }} run
96+
97+
test-complete:
98+
name: Test complete
99+
100+
needs:
101+
[
102+
test,
103+
test-upstream-and-min-deps,
104+
]
105+
if: always()
106+
runs-on: ubuntu-latest
107+
steps:
108+
- name: Check failure
109+
if: |
110+
contains(needs.*.result, 'failure') ||
111+
contains(needs.*.result, 'cancelled')
112+
run: exit 1
113+
- name: Success
114+
run: echo Success!

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ default_language_version:
77
python: python3
88
repos:
99
- repo: https://github.com/astral-sh/ruff-pre-commit
10-
rev: v0.8.0
10+
rev: v0.8.2
1111
hooks:
1212
- id: ruff
1313
args: ["--fix", "--show-fixes"]

docs/contributing.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,11 @@ the following::
9292
$ mkdir -p ~/pyenv/zarr-dev
9393
$ python -m venv ~/pyenv/zarr-dev
9494
$ source ~/pyenv/zarr-dev/bin/activate
95-
$ pip install -r requirements_dev_minimal.txt -r requirements_dev_numpy.txt
96-
$ pip install -e .[docs]
95+
$ pip install -e .[test,docs]
9796

9897
To verify that your development environment is working, you can run the unit tests::
9998

100-
$ python -m pytest -v zarr
99+
$ python -m pytest -v tests
101100

102101
Creating a branch
103102
~~~~~~~~~~~~~~~~~
@@ -149,7 +148,7 @@ and invoke::
149148
Some tests require optional dependencies to be installed, otherwise
150149
the tests will be skipped. To install all optional dependencies, run::
151150

152-
$ pip install -r requirements_dev_optional.txt
151+
$ pip install pytest-doctestplus
153152

154153
To also run the doctests within docstrings (requires optional
155154
dependencies to be installed), run::
@@ -234,7 +233,7 @@ should run and pass as doctests under Python 3.8. To run doctests,
234233
activate your development environment, install optional requirements,
235234
and run::
236235

237-
$ python -m pytest -v --doctest-plus zarr
236+
$ python -m pytest -v --doctest-plus tests
238237

239238
Zarr uses Sphinx for documentation, hosted on readthedocs.org. Documentation is
240239
written in the RestructuredText markup language (.rst files) in the ``docs`` folder.

docs/installation.rst

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
11
Installation
22
============
33

4-
Zarr depends on NumPy. It is generally best to `install NumPy
5-
<https://numpy.org/doc/stable/user/install.html>`_ first using whatever method is most
6-
appropriate for your operating system and Python distribution. Other dependencies should be
7-
installed automatically if using one of the installation methods below.
4+
pip
5+
---
86

9-
Note: Zarr has endorsed `Scientific-Python SPEC 0 <https://scientific-python.org/specs/spec-0000/>`_ and now follows the version support window as outlined below:
7+
.. code-block:: console
108
11-
- Python: 36 months after initial release
12-
- Core package dependencies (e.g. NumPy): 24 months after initial release
9+
$ pip install zarr
1310
14-
Install Zarr from PyPI::
11+
There are a number of optional dependency groups you can install for extra functionality.
12+
These can be installed using ``pip install "zarr[<extra>]"``, e.g. ``pip install "zarr[gpu]"``
1513

16-
$ pip install zarr
14+
- ``gpu``: support for GPUs
15+
- ``fsspec``: support for reading/writing to remote data stores
16+
- ``tree``: support for pretty printing of directory trees
1717

18-
Alternatively, install Zarr via conda::
18+
conda
19+
-----
20+
21+
.. code-block:: console
1922
2023
$ conda install -c conda-forge zarr
2124
22-
To install the latest development version of Zarr, you can use pip with the
23-
latest GitHub main::
25+
Conda does not support optional dependencies, so you will have to manually install any packages
26+
needed to enable extra functionality.
27+
28+
Dependency support
29+
------------------
30+
Zarr has endorsed `Scientific-Python SPEC 0 <https://scientific-python.org/specs/spec-0000/>`_ and now follows the version support window as outlined below:
2431

25-
$ pip install git+https://github.com/zarr-developers/zarr-python.git
32+
- Python: 36 months after initial release
33+
- Core package dependencies (e.g. NumPy): 24 months after initial release
2634

27-
To work with Zarr source code in development, see `Contributing <contributing.html>`_.
35+
Development
36+
-----------
37+
To install the latest development version of Zarr, see `the contributing guide <contributing.html>`_.

docs/release.rst

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,32 @@ Release notes
1818
See `GH1777 <https://github.com/zarr-developers/zarr-python/issues/1777>`_ for more details on the upcoming
1919
3.0 release.
2020

21+
.. release_3.0.0-beta:
22+
23+
3.0.0-beta series
24+
-----------------
25+
26+
.. warning::
27+
Zarr-Python 3.0.0-beta is a pre-release of the upcoming 3.0 release. This release is not feature complete or
28+
expected to be ready for production applications.
29+
30+
.. note::
31+
The complete release notes for 3.0 have not been added to this document yet. See the
32+
`3.0.0-beta <https://github.com/zarr-developers/zarr-python/releases/tag/v3.0.0-beta>`_ release on GitHub
33+
for a record of changes included in this release.
34+
35+
Dependency Changes
36+
~~~~~~~~~~~~~~~~~~
37+
38+
* fsspec was moved from a required dependency to an optional one. Users should install
39+
fsspec and any relevant implementations (e.g. s3fs) before using the ``RemoteStore``.
40+
By :user:`Joe Hamman <jhamman>` :issue:`2391`.
41+
42+
2143
.. release_3.0.0-alpha:
2244
23-
3.0.0-alpha
24-
-----------
45+
3.0.0-alpha series
46+
------------------
2547

2648
.. warning::
2749
Zarr-Python 3.0.0-alpha is a pre-release of the upcoming 3.0 release. This release is not feature complete or

pyproject.toml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ requires-python = ">=3.11"
2828
dependencies = [
2929
'numpy>=1.25',
3030
'numcodecs[crc32c]>=0.14',
31-
'fsspec>=2022.10.0',
32-
'typing_extensions>=4.6',
31+
'typing_extensions>=4.9',
3332
'donfig>=0.8',
3433
]
3534

@@ -54,16 +53,16 @@ license = {text = "MIT License"}
5453
keywords = ["Python", "compressed", "ndimensional-arrays", "zarr"]
5554

5655
[project.optional-dependencies]
56+
fsspec = [
57+
"fsspec>=2023.10.0",
58+
]
5759
test = [
5860
"coverage",
5961
"pytest",
6062
"pytest-cov",
61-
"msgpack",
6263
"s3fs",
6364
"pytest-asyncio",
6465
"moto[s3]",
65-
"flask-cors",
66-
"flask",
6766
"requests",
6867
"mypy",
6968
"hypothesis",
@@ -81,7 +80,7 @@ gpu = [
8180
docs = [
8281
'sphinx==8.1.3',
8382
'sphinx-autobuild>=2021.3.14',
84-
'sphinx-autoapi==3.3.3',
83+
'sphinx-autoapi==3.4.0',
8584
'sphinx_design',
8685
'sphinx-issues',
8786
'sphinx-copybutton',
@@ -224,7 +223,7 @@ dependencies = [
224223
'fsspec==2022.10.0',
225224
's3fs==2022.10.0',
226225
'universal_pathlib==0.0.22',
227-
'typing_extensions==4.6.*', # 4.5 needed for @deprecated, 4.6 for Buffer
226+
'typing_extensions==4.9.*',
228227
'donfig==0.8.*',
229228
# test deps
230229
'hypothesis',
@@ -294,19 +293,14 @@ extend-select = [
294293
"W", # pycodestyle warnings
295294
]
296295
ignore = [
297-
"ANN101", # deprecated
298-
"ANN102", # deprecated
299296
"ANN401",
300-
"PT004", # deprecated
301-
"PT005", # deprecated
302297
"PT011", # TODO: apply this rule
303298
"PT012", # TODO: apply this rule
304299
"RET505",
305300
"RET506",
306301
"RUF005",
307302
"SIM108",
308303
"TRY003",
309-
"UP027", # deprecated
310304
"UP038", # https://github.com/astral-sh/ruff/issues/7871
311305
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
312306
"W191",
@@ -347,6 +341,7 @@ ignore_errors = true
347341

348342
[[tool.mypy.overrides]]
349343
module = [
344+
"zarr.testing.stateful", # lots of hypothesis decorator errors
350345
"tests.package_with_entrypoint.*",
351346
"tests.test_codecs.test_codecs",
352347
"tests.test_codecs.test_transpose",

src/zarr/api/asynchronous.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import numpy as np
99
import numpy.typing as npt
10+
from typing_extensions import deprecated
1011

1112
from zarr.core.array import Array, AsyncArray, get_array_metadata
1213
from zarr.core.buffer import NDArrayLike
@@ -535,8 +536,29 @@ async def save_group(
535536
await asyncio.gather(*aws)
536537

537538

538-
async def tree(*args: Any, **kwargs: Any) -> None:
539-
raise NotImplementedError
539+
@deprecated("Use AsyncGroup.tree instead.")
540+
async def tree(grp: AsyncGroup, expand: bool | None = None, level: int | None = None) -> Any:
541+
"""Provide a rich display of the hierarchy.
542+
543+
Parameters
544+
----------
545+
grp : Group
546+
Zarr or h5py group.
547+
expand : bool, optional
548+
Only relevant for HTML representation. If True, tree will be fully expanded.
549+
level : int, optional
550+
Maximum depth to descend into hierarchy.
551+
552+
Returns
553+
-------
554+
TreeRepr
555+
A pretty-printable object displaying the hierarchy.
556+
557+
.. deprecated:: 3.0.0
558+
`zarr.tree()` is deprecated and will be removed in a future release.
559+
Use `group.tree()` instead.
560+
"""
561+
return await grp.tree(expand=expand, level=level)
540562

541563

542564
async def array(
@@ -743,12 +765,12 @@ async def open_group(
743765
Store or path to directory in file system or name of zip file.
744766
745767
Strings are interpreted as paths on the local file system
746-
and used as the ``root`` argument to :class:`zarr.store.LocalStore`.
768+
and used as the ``root`` argument to :class:`zarr.storage.LocalStore`.
747769
748770
Dictionaries are used as the ``store_dict`` argument in
749-
:class:`zarr.store.MemoryStore``.
771+
:class:`zarr.storage.MemoryStore``.
750772
751-
By default (``store=None``) a new :class:`zarr.store.MemoryStore`
773+
By default (``store=None``) a new :class:`zarr.storage.MemoryStore`
752774
is created.
753775
754776
mode : {'r', 'r+', 'a', 'w', 'w-'}, optional

src/zarr/api/synchronous.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from typing import TYPE_CHECKING, Any, Literal
44

5+
from typing_extensions import deprecated
6+
57
import zarr.api.asynchronous as async_api
68
from zarr._compat import _deprecate_positional_args
79
from zarr.core.array import Array, AsyncArray
@@ -165,8 +167,9 @@ def save_group(
165167
)
166168

167169

168-
def tree(*args: Any, **kwargs: Any) -> None:
169-
return sync(async_api.tree(*args, **kwargs))
170+
@deprecated("Use Group.tree instead.")
171+
def tree(grp: Group, expand: bool | None = None, level: int | None = None) -> Any:
172+
return sync(async_api.tree(grp._async_group, expand=expand, level=level))
170173

171174

172175
# TODO: add type annotations for kwargs

src/zarr/codecs/_v2.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import TYPE_CHECKING
66

77
import numcodecs
8-
from numcodecs.compat import ensure_ndarray_like
8+
from numcodecs.compat import ensure_bytes, ensure_ndarray_like
99

1010
from zarr.abc.codec import ArrayBytesCodec
1111
from zarr.registry import get_ndbuffer_class
@@ -68,6 +68,9 @@ async def _encode_single(
6868
) -> Buffer | None:
6969
chunk = chunk_array.as_ndarray_like()
7070

71+
# ensure contiguous and correct order
72+
chunk = chunk.astype(chunk_spec.dtype, order=chunk_spec.order, copy=False)
73+
7174
# apply filters
7275
if self.filters:
7376
for f in self.filters:
@@ -83,6 +86,7 @@ async def _encode_single(
8386
else:
8487
cdata = chunk
8588

89+
cdata = ensure_bytes(cdata)
8690
return chunk_spec.prototype.buffer.from_bytes(cdata)
8791

8892
def compute_encoded_size(self, _input_byte_length: int, _chunk_spec: ArraySpec) -> int:

0 commit comments

Comments
 (0)