Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7f38776
fix(sharding): validate the inner codec chain against the array's fil…
d-v-b Nov 13, 2026
9942717
docs: add changelog fragments for #446
d-v-b Nov 13, 2026
39eba05
docs: renumber changelog fragments for #4633
d-v-b Nov 14, 2026
8d801dd
test: check zarr-python's verdict on zarr-metadata's array documents
d-v-b Nov 14, 2026
a5497b8
test: bound drawn rectilinear runs and keep zarr-metadata out of min_…
d-v-b Nov 14, 2026
9bee0c0
fix(metadata): validate codecs after a transpose against the transpos…
d-v-b Nov 16, 2026
4528fc7
docs: add changelog fragment for #449
d-v-b Nov 16, 2026
9b59c5a
Merge remote-tracking branch 'origin/fix/sharding-probe-threaded-fill…
d-v-b Nov 30, 2026
0431a03
fix(sharding): open stored arrays whose shards the inner chunk shape …
d-v-b Nov 30, 2026
f27f64c
test: check shard divisibility through check_chunk_grid
d-v-b Nov 30, 2026
24ab145
fix(sharding): skip shard checks against a grid of another dimensiona…
d-v-b Nov 30, 2026
1051fc0
fix(sharding): check shards against the chunk spec the codecs leave
d-v-b Nov 30, 2026
db7d0b8
fix(sharding): skip a rectilinear grid that a codec left stale
d-v-b Nov 30, 2026
bbd2212
fix(sharding): explain a shard with another number of dimensions
d-v-b Nov 30, 2026
e3d4255
fix(sharding): name a dimension mismatch when reading or writing a shard
d-v-b Nov 30, 2026
eccbae5
test: pin the first-shard check of a stale rectilinear grid
d-v-b Nov 30, 2026
45d9ddf
Merge remote-tracking branch 'upstream/main' into claude/zarr-pr-4633…
d-v-b Dec 1, 2026
be853eb
test: drop the integer-array bytes fill value divergence
d-v-b Dec 1, 2026
7097a80
chore(deps): bump the python-dependencies group with 9 updates (#4690)
dependabot[bot] Dec 3, 2026
13f4bf5
chore(deps): bump the actions group with 2 updates (#4689)
dependabot[bot] Dec 3, 2026
d7963f9
Merge remote-tracking branch 'upstream/main' into claude/zarr-pr-4633…
d-v-b Dec 3, 2026
62ac857
test: bump zarr-metadata to 0.9.0 and drop the empty edges divergence
d-v-b Dec 3, 2026
0a1bb3d
fix(sharding): reject a shard whose rank differs from the chunk grid's
d-v-b Dec 3, 2026
0f260ad
fix(metadata): check the chunk grid's rank before validating codecs
d-v-b Dec 3, 2026
f5d33ae
Merge branch 'fix/sharding-probe-threaded-fill-value' (#4633) into fi…
d-v-b Dec 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
repo: casey/just
version: 1.58.0
- name: Run the benchmarks
uses: CodSpeedHQ/action@af75f77f17a054769abefaa42fe8dc2975469b5f # v5.6.3
uses: CodSpeedHQ/action@b1f28b5eccf7cb5bfe6a2a89cb3053eb67f1150c # v5.8.0
env:
ZARR_BENCHMARK_CLEAR_CACHE: '1'
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zizmor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
persist-credentials: false

- name: Run zizmor
uses: zizmorcore/zizmor-action@45d7276c9ca790aabd705e31ca99c6185c3e76dd # v0.8.1
uses: zizmorcore/zizmor-action@1b4550e929643b8b26a62303c6bd64814271a4f1 # v0.9.2
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ coverage-serve *args:

# Run slow Hypothesis tests and write coverage.xml
hypothesis *args:
hatch run {{ quote(hatch_env) }}:coverage run --source=src -m pytest -nauto --run-slow-hypothesis tests/test_properties.py tests/test_store/test_stateful* tests/test_array_stateful.py "$@"
hatch run {{ quote(hatch_env) }}:coverage run --source=src -m pytest -nauto --run-slow-hypothesis tests/test_properties.py tests/test_store/test_stateful* tests/test_array_stateful.py tests/test_zarr_metadata_conformance.py "$@"
hatch run {{ quote(hatch_env) }}:coverage xml

# Validate executable documentation code blocks
Expand Down
1 change: 1 addition & 0 deletions changes/449.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix validation of the codecs after a `TransposeCodec`, which used the untransposed chunk grid: a sharding codec whose inner chunk shape divided only the untransposed chunk was accepted and read back wrong data, and a valid one was refused. A sharding codec whose inner chunk shape does not divide its shards is now refused when array metadata is stored instead of when it is read, so arrays stored that way open, and so do their groups. Reading their shards, or writing data to them, raises an error instead of returning wrong data or dropping data. A sharding codec after a filter that flattens chunks, such as `PackBits`, is checked against the flattened shards of a regular chunk grid.
1 change: 1 addition & 0 deletions changes/449.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `resolve_chunk_grid` to codecs, the chunk-grid counterpart of `resolve_metadata`. A codec that changes the shape of a chunk implements it to give the chunk grid that the codecs after it see. `TransposeCodec` permutes the grid.
1 change: 1 addition & 0 deletions changes/4633.bugfix.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Creating a sharded array no longer fails when the codecs inside the shard cannot encode the data type's default value, for example a `scale_offset` filter that maps only part of the data type's range. The inner codecs are now checked against the array's fill value, which must still be encodable.
1 change: 1 addition & 0 deletions changes/4633.bugfix.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Creating or opening an array no longer rejects a codec placed after a data-type-changing codec such as `cast_value` because its configuration would be invalid for the array's original data type. Each codec is now checked against the data type it receives.
5 changes: 5 additions & 0 deletions docs/user-guide/extending.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ Custom codecs should also implement the following methods:
array metadata. It should raise errors if not.
- `resolve_metadata` (optional), which is important for codecs that change the shape,
dtype or fill value of a chunk.
- `resolve_chunk_grid` (optional), which codecs that change the shape of a chunk
implement to return the array's chunk grid as the codecs after them see it. The
`validate` method of each later codec in the array's codecs receives that grid. The
default returns the grid unchanged, which is right for codecs that keep the shape of a
chunk.
- `evolve_from_array_spec` (optional), which can be useful for automatically filling in
codec configuration metadata from the array metadata.

Expand Down
23 changes: 15 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,41 +111,47 @@ homepage = "https://github.com/zarr-developers/zarr-python"
# pins deliberately, e.g. via dependabot or `uv lock --upgrade`.
[dependency-groups]
test = [
"coverage==7.17.3",
"coverage==7.17.5",
"pytest==9.2.0",
"pytest-asyncio==1.5.0",
"pytest-cov==7.1.0",
"numpydoc==1.11.0",
"hypothesis==6.170.15",
"hypothesis==6.170.17",
"pytest-reportlog==1.0.0",
"pytest-xdist==3.8.0",
"pytest-benchmark==5.3.1",
"pytest-codspeed==5.0.4",
"uv==0.13.9",
"uv==0.13.10",
]
# tests/test_zarr_metadata_conformance.py draws array documents from zarr-metadata's
# strategies. Its own group, because zarr-metadata needs a newer typing-extensions than
# the `min_deps` env pins; the test skips where it is not installed.
conformance = [
"zarr-metadata[testing]==0.9.0",
]
remote-tests = [
{include-group = "test"},
"fsspec>=2023.10.0",
"obstore>=0.5.1",
"botocore",
"s3fs>=2023.10.0",
"moto[s3,server]==5.2.5",
"moto[s3,server]==5.2.6",
"requests==2.34.2",
]
release = [
"towncrier==26.9.0",
]
docs = [
# Doc building
"mkdocs-material[imaging]==9.8.1",
"mkdocs-material[imaging]==9.8.2",
"mkdocs==1.6.1",
"mkdocstrings==1.0.8",
"mkdocstrings-python==2.0.11",
"mike==2.2.0",
"mkdocs-redirects==1.2.3",
"markdown-exec[ansi]==1.13.0",
"markdown-exec[ansi]==1.14.0",
"griffe-inherited-docstrings==1.1.4",
"ruff==0.17.5",
"ruff==0.17.6",
# Changelog generation
{include-group = "release"},
# Optional dependencies to run examples
Expand All @@ -156,6 +162,7 @@ docs = [
]
dev = [
{include-group = "test"},
{include-group = "conformance"},
{include-group = "remote-tests"},
{include-group = "docs"},
"universal-pathlib",
Expand Down Expand Up @@ -188,7 +195,7 @@ hooks.vcs.version-file = "src/zarr/_version.py"
dependency-groups = ["dev"]

[tool.hatch.envs.test]
dependency-groups = ["test"]
dependency-groups = ["test", "conformance"]

[tool.hatch.envs.test.env-vars]

Expand Down
22 changes: 22 additions & 0 deletions src/zarr/abc/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,28 @@ def resolve_metadata(self, chunk_spec: ArraySpec) -> ArraySpec:
"""
return chunk_spec

def resolve_chunk_grid(self, chunk_grid: ChunkGridMetadata) -> ChunkGridMetadata:
"""The array's chunk grid as the codecs after this one see it.

A codec that changes the shape of a chunk returns the grid of the chunks it
encodes to, as `resolve_metadata` returns their spec. Array metadata validates
each of its codecs against the grid the codecs before it leave, and, for a
rectilinear grid, checks against it that a sharding codec's inner chunk shape
divides its shards before the metadata is stored. The default returns
`chunk_grid` unchanged, which holds for any codec that keeps a chunk's shape. A
codec that changes the shape of a chunk and keeps the default passes on a grid
that does not describe its chunks.

Parameters
----------
chunk_grid : ChunkGridMetadata

Returns
-------
ChunkGridMetadata
"""
return chunk_grid

def evolve_from_array_spec(self, array_spec: ArraySpec) -> Self:
"""Fills in codec configuration parameters that can be automatically
inferred from the array metadata.
Expand Down
Loading
Loading