Skip to content

Commit 78ab221

Browse files
committed
merge main into default-compressor
2 parents d6dc146 + 1a75957 commit 78ab221

30 files changed

+1516
-763
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: 2 additions & 4 deletions
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.7.3
10+
rev: v0.8.2
1111
hooks:
1212
- id: ruff
1313
args: ["--fix", "--show-fixes"]
@@ -28,10 +28,8 @@ repos:
2828
files: src|tests
2929
additional_dependencies:
3030
# Package dependencies
31-
- asciitree
32-
- crc32c
3331
- donfig
34-
- numcodecs
32+
- numcodecs[crc32c]
3533
- numpy
3634
- typing_extensions
3735
- universal-pathlib

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@
7878
</td>
7979
</tr>
8080
<tr>
81+
<td>Funding</td>
82+
<td>
83+
<a href="https://chanzuckerberg.com/eoss/">
84+
<img src="https://img.shields.io/badge/funded%20by-EOSS-FF414B.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0NSIgaGVpZ2h0PSI0NSI+PHBhdGggZD0iTTIyLjA5OCAyMS4wNzRjLTEuMjM1Ljg2LTIuNjggMS4zOTktNC42ODggMS40Mz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CZI's Essential Open Source Software for Science">
85+
</a>
86+
</td>
87+
</tr>
8188
<td>Citation</td>
8289
<td>
8390
<a href="https://doi.org/10.5281/zenodo.3773450">

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: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,9 @@ maintainers = [
2626
requires-python = ">=3.11"
2727
# If you add a new dependency here, please also add it to .pre-commit-config.yml
2828
dependencies = [
29-
'asciitree',
3029
'numpy>=1.25',
31-
'numcodecs>=0.14',
32-
'fsspec>=2022.10.0',
33-
'crc32c>=2.3',
34-
'typing_extensions>=4.6',
30+
'numcodecs[crc32c]>=0.14',
31+
'typing_extensions>=4.9',
3532
'donfig>=0.8',
3633
]
3734

@@ -56,16 +53,16 @@ license = {text = "MIT License"}
5653
keywords = ["Python", "compressed", "ndimensional-arrays", "zarr"]
5754

5855
[project.optional-dependencies]
56+
fsspec = [
57+
"fsspec>=2023.10.0",
58+
]
5959
test = [
6060
"coverage",
6161
"pytest",
6262
"pytest-cov",
63-
"msgpack",
6463
"s3fs",
6564
"pytest-asyncio",
6665
"moto[s3]",
67-
"flask-cors",
68-
"flask",
6966
"requests",
7067
"mypy",
7168
"hypothesis",
@@ -83,7 +80,7 @@ gpu = [
8380
docs = [
8481
'sphinx==8.1.3',
8582
'sphinx-autobuild>=2021.3.14',
86-
'sphinx-autoapi==3.3.3',
83+
'sphinx-autoapi==3.4.0',
8784
'sphinx_design',
8885
'sphinx-issues',
8986
'sphinx-copybutton',
@@ -193,7 +190,6 @@ dependencies = [
193190
'fsspec @ git+https://github.com/fsspec/filesystem_spec',
194191
's3fs @ git+https://github.com/fsspec/s3fs',
195192
'universal_pathlib @ git+https://github.com/fsspec/universal_pathlib',
196-
'crc32c @ git+https://github.com/ICRAR/crc32c',
197193
'typing_extensions @ git+https://github.com/python/typing_extensions',
198194
'donfig @ git+https://github.com/pytroll/donfig',
199195
# test deps
@@ -227,8 +223,7 @@ dependencies = [
227223
'fsspec==2022.10.0',
228224
's3fs==2022.10.0',
229225
'universal_pathlib==0.0.22',
230-
'crc32c==2.3.*',
231-
'typing_extensions==4.6.*', # 4.5 needed for @deprecated, 4.6 for Buffer
226+
'typing_extensions==4.9.*',
232227
'donfig==0.8.*',
233228
# test deps
234229
'hypothesis',
@@ -298,19 +293,14 @@ extend-select = [
298293
"W", # pycodestyle warnings
299294
]
300295
ignore = [
301-
"ANN101", # deprecated
302-
"ANN102", # deprecated
303296
"ANN401",
304-
"PT004", # deprecated
305-
"PT005", # deprecated
306297
"PT011", # TODO: apply this rule
307298
"PT012", # TODO: apply this rule
308299
"RET505",
309300
"RET506",
310301
"RUF005",
311302
"SIM108",
312303
"TRY003",
313-
"UP027", # deprecated
314304
"UP038", # https://github.com/astral-sh/ruff/issues/7871
315305
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
316306
"W191",
@@ -351,6 +341,7 @@ ignore_errors = true
351341

352342
[[tool.mypy.overrides]]
353343
module = [
344+
"zarr.testing.stateful", # lots of hypothesis decorator errors
354345
"tests.package_with_entrypoint.*",
355346
"tests.test_codecs.test_codecs",
356347
"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
@@ -493,8 +494,29 @@ async def save_group(
493494
await asyncio.gather(*aws)
494495

495496

496-
async def tree(*args: Any, **kwargs: Any) -> None:
497-
raise NotImplementedError
497+
@deprecated("Use AsyncGroup.tree instead.")
498+
async def tree(grp: AsyncGroup, expand: bool | None = None, level: int | None = None) -> Any:
499+
"""Provide a rich display of the hierarchy.
500+
501+
Parameters
502+
----------
503+
grp : Group
504+
Zarr or h5py group.
505+
expand : bool, optional
506+
Only relevant for HTML representation. If True, tree will be fully expanded.
507+
level : int, optional
508+
Maximum depth to descend into hierarchy.
509+
510+
Returns
511+
-------
512+
TreeRepr
513+
A pretty-printable object displaying the hierarchy.
514+
515+
.. deprecated:: 3.0.0
516+
`zarr.tree()` is deprecated and will be removed in a future release.
517+
Use `group.tree()` instead.
518+
"""
519+
return await grp.tree(expand=expand, level=level)
498520

499521

500522
async def array(
@@ -653,12 +675,12 @@ async def open_group(
653675
Store or path to directory in file system or name of zip file.
654676
655677
Strings are interpreted as paths on the local file system
656-
and used as the ``root`` argument to :class:`zarr.store.LocalStore`.
678+
and used as the ``root`` argument to :class:`zarr.storage.LocalStore`.
657679
658680
Dictionaries are used as the ``store_dict`` argument in
659-
:class:`zarr.store.MemoryStore``.
681+
:class:`zarr.storage.MemoryStore``.
660682
661-
By default (``store=None``) a new :class:`zarr.store.MemoryStore`
683+
By default (``store=None``) a new :class:`zarr.storage.MemoryStore`
662684
is created.
663685
664686
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
@@ -155,8 +157,9 @@ def save_group(
155157
)
156158

157159

158-
def tree(*args: Any, **kwargs: Any) -> None:
159-
return sync(async_api.tree(*args, **kwargs))
160+
@deprecated("Use Group.tree instead.")
161+
def tree(grp: Group, expand: bool | None = None, level: int | None = None) -> Any:
162+
return sync(async_api.tree(grp._async_group, expand=expand, level=level))
160163

161164

162165
# 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
@@ -6,7 +6,7 @@
66

77
import numcodecs
88
import numpy as np
9-
from numcodecs.compat import ensure_ndarray_like
9+
from numcodecs.compat import ensure_bytes, ensure_ndarray_like
1010

1111
from zarr.abc.codec import ArrayBytesCodec
1212
from zarr.registry import get_ndbuffer_class
@@ -73,6 +73,9 @@ async def _encode_single(
7373
) -> Buffer | None:
7474
chunk = chunk_array.as_ndarray_like()
7575

76+
# ensure contiguous and correct order
77+
chunk = chunk.astype(chunk_spec.dtype, order=chunk_spec.order, copy=False)
78+
7679
# apply filters
7780
if self.filters:
7881
for f in self.filters:
@@ -88,6 +91,7 @@ async def _encode_single(
8891
else:
8992
cdata = chunk
9093

94+
cdata = ensure_bytes(cdata)
9195
return chunk_spec.prototype.buffer.from_bytes(cdata)
9296

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

0 commit comments

Comments
 (0)