Skip to content

Commit

Permalink
Merge branch 'main' into deterministic-chunk-padding
Browse files Browse the repository at this point in the history
  • Loading branch information
brokkoli71 committed Jan 23, 2025
2 parents 167afe3 + 0c154c3 commit 6ccfe95
Show file tree
Hide file tree
Showing 30 changed files with 213 additions and 76 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
TODO:
* [ ] Add unit tests and/or doctests in docstrings
* [ ] Add docstrings and API docs for any new/modified user-facing classes and functions
* [ ] New/modified features documented in docs/tutorial.rst
* [ ] Changes documented in docs/release.rst
* [ ] New/modified features documented in `docs/user-guide/*.rst`
* [ ] Changes documented as a new file in `changes/`
* [ ] GitHub Actions have all passed
* [ ] Test coverage is 100% (Codecov passes)
18 changes: 5 additions & 13 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
---
version: 2
updates:
# Updates for v3 branch (the default branch)
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
groups:
actions:
patterns:
- "*"
# Updates for main
- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand All @@ -19,19 +11,19 @@ updates:
patterns:
- "*"

# Same updates, but for main branch
# Updates for support/v2 branch
- package-ecosystem: "pip"
directory: "/"
target-branch: "main"
target-branch: "support/v2"
schedule:
interval: "daily"
interval: "weekly"
groups:
requirements:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/"
target-branch: "main"
target-branch: "support/v2"
schedule:
interval: "weekly"
groups:
Expand Down
6 changes: 4 additions & 2 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
needs release notes:
- all: ['!docs/release.rst']
- needs release notes:
- all:
- changed-files:
- any-glob-to-any-file: 'changes/*.rst'
7 changes: 5 additions & 2 deletions .github/workflows/needs_release_notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ on:
- pull_request_target

jobs:
triage:
labeler:
if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' }} && ${{ github.event.pull_request.user.login != 'pre-commit-ci[bot]' }}
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@main
- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
sync-labels: true
6 changes: 5 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ci:
default_stages: [pre-commit, pre-push]
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.9.1
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand Down Expand Up @@ -49,3 +49,7 @@ repos:
rev: v1.8.0
hooks:
- id: numpydoc-validation
- repo: https://github.com/twisted/towncrier
rev: 23.11.0
hooks:
- id: towncrier-check
7 changes: 7 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ build:
os: ubuntu-22.04
tools:
python: "3.12"
jobs:
pre_build:
- |
if [ "$READTHEDOCS_VERSION_TYPE" != "tag" ];
then
towncrier build --version Unreleased --yes;
fi
sphinx:
configuration: docs/conf.py
Expand Down
1 change: 1 addition & 0 deletions changes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.gitignore
1 change: 1 addition & 0 deletions changes/2533.bigfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Wrap sync fsspec filesystems with AsyncFileSystemWrapper in xarray.to_zarr
1 change: 1 addition & 0 deletions changes/2681.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added backwards compatibility for Zarr format 2 structured arrays.
2 changes: 2 additions & 0 deletions changes/2736.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Changed the machinery for creating changelog entries.
Now individual entries should be added as files to the `changes` directory in the `zarr-python` repository, instead of directly to the changelog file.
14 changes: 14 additions & 0 deletions changes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Writing a changelog entry
-------------------------

Please put a new file in this directory named `xxxx.<type>.rst`, where

- `xxxx` is the pull request number associated with this entry
- `<type>` is one of:
- feature
- bugfix
- doc
- removal
- misc

Inside the file, please write a short description of what you have changed, and how it impacts users of `zarr-python`.
5 changes: 1 addition & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@

import os
import sys
from importlib.metadata import version as get_version
from typing import Any

import sphinx
import sphinx.application

from importlib.metadata import version as get_version

import sphinx

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand Down
24 changes: 13 additions & 11 deletions docs/developers/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ you can do something like the following::
To verify that your development environment is working, you can run the unit tests
for one of the test environments, e.g.::

$ hatch env run --env test.py3.12-2.1-optional run
$ hatch env run --env test.py3.12-2.1-optional run-pytest

Creating a branch
~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -140,7 +140,7 @@ Zarr includes a suite of unit tests. The simplest way to run the unit tests
is to activate your development environment
(see `creating a development environment`_ above) and invoke::

$ hatch env run --env test.py3.12-2.1-optional run
$ hatch env run --env test.py3.12-2.1-optional run-pytest

All tests are automatically run via GitHub Actions for every pull
request and must pass before code can be accepted. Test coverage is
Expand Down Expand Up @@ -190,9 +190,13 @@ Both unit tests and docstring doctests are included when computing coverage. Run

$ hatch env run --env test.py3.12-2.1-optional run-coverage

will automatically run the test suite with coverage and produce a coverage report.
will automatically run the test suite with coverage and produce a XML coverage report.
This should be 100% before code can be accepted into the main code base.

You can also generate an HTML coverage report by running::

$ hatch env run --env test.py3.12-2.1-optional run-coverage-html

When submitting a pull request, coverage will also be collected across all supported
Python versions via the Codecov service, and will be reported back within the pull
request. Codecov coverage must also be 100% before code can be accepted.
Expand All @@ -212,8 +216,8 @@ The documentation consists both of prose and API documentation. All user-facing
and functions are included in the API documentation, under the ``docs/api`` folder
using the `autodoc <https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html>`_
extension to sphinx. Any new features or important usage information should be included in the
user-guide (``docs/user-guide``). Any changes should also be included in the release
notes (``docs/release-notes.rst``).
user-guide (``docs/user-guide``). Any changes should also be included as a new file in the
:file:`changes` directory.

The documentation can be built locally by running::

Expand Down Expand Up @@ -331,11 +335,9 @@ Release procedure

Pre-release
"""""""""""
1. Make sure that all pull requests which will be
included in the release have been properly documented in
:file:`docs/release-notes.rst`.
2. Rename the "Unreleased" section heading in :file:`docs/release-notes.rst`
to the version you are about to release.
1. Make sure that all pull requests which will be included in the release
have been properly documented as changelog files in :file:`changes`.
2. Run ``towncrier build --version x.y.z`` to create the changelog.

Releasing
"""""""""
Expand All @@ -348,7 +350,7 @@ appropriate suffix (e.g. `v0.0.0a1` or `v0.0.0rc2`).

Set the description of the release to::

See release notes https://zarr.readthedocs.io/en/stable/release.html#release-0-0-0
See release notes https://zarr.readthedocs.io/en/stable/release-notes.html#release-0-0-0

replacing the correct version numbers. For pre-release versions,
the URL should omit the pre-release suffix, e.g. "a1" or "rc1".
Expand Down
38 changes: 27 additions & 11 deletions docs/release-notes.rst
Original file line number Diff line number Diff line change
@@ -1,33 +1,49 @@
Release notes
=============

Unreleased
----------
.. towncrier release notes start
New features
~~~~~~~~~~~~
3.0.1 (Jan. 17, 2025)
---------------------

Bug fixes
~~~~~~~~~
* Fixes ``order`` argument for Zarr format 2 arrays (:issue:`2679`).

* Fixes a bug that prevented reading Zarr format 2 data with consolidated metadata written using ``zarr-python`` version 2 (:issue:`2694`).
* Fixes a bug that prevented reading Zarr format 2 data with consolidated
metadata written using ``zarr-python`` version 2 (:issue:`2694`).

* Ensure that compressor=None results in no compression when writing Zarr
format 2 data (:issue:`2708`).

* Fix for empty consolidated metadata dataset: backwards compatibility with
Zarr-Python 2 (:issue:`2695`).

Documentation
~~~~~~~~~~~~~
* Add v3.0.0 release announcement banner (:issue:`2677`).

* Ensure that compressor=None results in no compression when writing Zarr format 2 data (:issue:`2708`)
* Quickstart guide alignment with V3 API (:issue:`2697`).

Behaviour changes
~~~~~~~~~~~~~~~~~
* Fix doctest failures related to numcodecs 0.15 (:issue:`2727`).

Other
~~~~~
* Removed some unnecessary files from the source distribution
to reduce its size. (:issue:`2686`)
to reduce its size. (:issue:`2686`).

* Enable codecov in GitHub actions (:issue:`2682`).

* Speed up hypothesis tests (:issue:`2650`).

* Remove multiple imports for an import name (:issue:`2723`).


.. _release_3.0.0:

3.0.0
-----
3.0.0 (Jan. 9, 2025)
--------------------

3.0.0 is a new major release of Zarr-Python, with many breaking changes.
See the :ref:`v3 migration guide` for a listing of what's changed.
Expand Down
4 changes: 2 additions & 2 deletions docs/user-guide/arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ built-in delta filter::
>>> data = np.arange(100000000, dtype='int32').reshape(10000, 10000)
>>> z = zarr.create_array(store='data/example-7.zarr', shape=data.shape, dtype=data.dtype, chunks=(1000, 1000), compressors=compressors)
>>> z.compressors
(_make_bytes_bytes_codec.<locals>._Codec(codec_name='numcodecs.lzma', codec_config={'id': 'lzma', 'filters': [{'id': 3, 'dist': 4}, {'id': 33, 'preset': 1}]}),)
(LZMA(codec_name='numcodecs.lzma', codec_config={'filters': [{'id': 3, 'dist': 4}, {'id': 33, 'preset': 1}]}),)

The default compressor can be changed by setting the value of the using Zarr's
:ref:`user-guide-config`, e.g.::
Expand Down Expand Up @@ -292,7 +292,7 @@ Here is an example using a delta filter with the Blosc compressor::
Order : C
Read-only : False
Store type : LocalStore
Filters : (_make_array_array_codec.<locals>._Codec(codec_name='numcodecs.delta', codec_config={'id': 'delta', 'dtype': 'int32'}),)
Filters : (Delta(codec_name='numcodecs.delta', codec_config={'dtype': 'int32'}),)
Serializer : BytesCodec(endian=<Endian.little: 'little'>)
Compressors : (BloscCodec(typesize=4, cname=<BloscCname.zstd: 'zstd'>, clevel=1, shuffle=<BloscShuffle.shuffle: 'shuffle'>, blocksize=0),)
No. bytes : 400000000 (381.5M)
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ This is the current default configuration::
'level': 0}},
'v2_default_filters': {'bytes': [{'id': 'vlen-bytes'}],
'numeric': None,
'raw': None,
'string': [{'id': 'vlen-utf8'}]},
'v3_default_compressors': {'bytes': [{'configuration': {'checksum': False,
'level': 0},
Expand Down
19 changes: 15 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ test = [
]
optional = ["rich", "universal-pathlib"]
docs = [
# Doc building
'sphinx==8.1.3',
'sphinx-autobuild>=2021.3.14',
'sphinx-autoapi==3.4.0',
Expand All @@ -94,6 +95,9 @@ docs = [
'sphinx-reredirects',
'pydata-sphinx-theme',
'numpydoc',
# Changelog generation
'towncrier',
# Optional dependencies to run examples
'numcodecs[msgpack]',
'rich',
's3fs',
Expand Down Expand Up @@ -149,7 +153,9 @@ features = ["gpu"]
[tool.hatch.envs.test.scripts]
run-coverage = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report xml --cov=src --junitxml=junit.xml -o junit_family=legacy"
run-coverage-gpu = "pip install cupy-cuda12x && pytest -m gpu --cov-config=pyproject.toml --cov=pkg --cov-report xml --cov=src --junitxml=junit.xml -o junit_family=legacy"
run-coverage-html = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report html --cov=src"
run = "run-coverage --no-cov"
run-pytest = "run"
run-verbose = "run-coverage --verbose"
run-mypy = "mypy src"
run-hypothesis = "pytest --hypothesis-profile ci tests/test_properties.py tests/test_store/test_stateful*"
Expand Down Expand Up @@ -228,11 +234,12 @@ See Spec 0000 for details and drop schedule: https://scientific-python.org/specs
"""
python = "3.11"
dependencies = [
'zarr[remote]',
'packaging==22.*',
'numpy==1.25.*',
'numcodecs==0.14.*', # 0.14 needed for zarr3 codecs
'fsspec==2022.10.0',
's3fs==2022.10.0',
'fsspec==2023.10.0',
's3fs==2023.10.0',
'universal_pathlib==0.0.22',
'typing_extensions==4.9.*',
'donfig==0.8.*',
Expand Down Expand Up @@ -326,8 +333,6 @@ ignore = [
"Q003",
"COM812",
"COM819",
"ISC001",
"ISC002",
]

[tool.ruff.lint.extend-per-file-ignores]
Expand Down Expand Up @@ -414,3 +419,9 @@ checks = [
"PR05",
"PR06",
]

[tool.towncrier]
directory = 'changes'
filename = "docs/release-notes.rst"
underlines = ["-", "~", "^"]
issue_format = ":issue:`{issue}`"
6 changes: 3 additions & 3 deletions src/zarr/codecs/sharding.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ async def get(
self, prototype: BufferPrototype, byte_range: ByteRequest | None = None
) -> Buffer | None:
assert byte_range is None, "byte_range is not supported within shards"
assert (
prototype == default_buffer_prototype()
), f"prototype is not supported within shards currently. diff: {prototype} != {default_buffer_prototype()}"
assert prototype == default_buffer_prototype(), (
f"prototype is not supported within shards currently. diff: {prototype} != {default_buffer_prototype()}"
)
return self.shard_dict.get(self.chunk_coords)


Expand Down
1 change: 0 additions & 1 deletion src/zarr/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
_parse_bytes_bytes_codec,
get_pipeline_class,
)
from zarr.storage import StoreLike
from zarr.storage._common import StorePath, ensure_no_existing_node, make_store_path

if TYPE_CHECKING:
Expand Down
4 changes: 3 additions & 1 deletion src/zarr/core/buffer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,9 @@ def all_equal(self, other: Any, equal_nan: bool = True) -> bool:
# every single time we have to write data?
_data, other = np.broadcast_arrays(self._data, other)
return np.array_equal(
self._data, other, equal_nan=equal_nan if self._data.dtype.kind not in "USTO" else False
self._data,
other,
equal_nan=equal_nan if self._data.dtype.kind not in "USTOV" else False,
)

def fill(self, value: Any) -> None:
Expand Down
Loading

0 comments on commit 6ccfe95

Please sign in to comment.