Repository navigation
Conversation
…nfig does not name Add tests/test_codecs/test_third_party_codecs.py, which runs imagecodecs' zarr 3 and numcodecs codecs, numcodecs' pcodec and zfpy codecs, and the zarrs codec pipeline through reads and writes whose prototype differs from the buffer kind zarr.config names, over v3, sharded, nested-sharded and v2 layouts. kvikio's GDSStore gets a case that runs only where kvikio installs. Move the fake device buffer kind, the prototype/config directions, the recording store and the round trip into tests/test_codecs/buffer_kinds.py so both suites share them; test_buffer_prototype.py checks what it did. The packages stay out of the default test environments: a `third-party-codecs` hatch environment, `just third-party-codecs`, and a CI job install and run them. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a round trip under a zarr.config buffer kind that cannot be built, which catches zarr building a buffer from zarr.config and converting it afterwards (V2Codec, the shard index, an empty shard reader). Document that the fake device array is host memory to C and Rust code, so the device directions do not show a package works on a GPU. Drop the kvikio case: no environment installs kvikio, and its zarr 3 integration is a store run with the fake kind, not CUDA. In CI, derive the import check from the cases, and fail if zarr does not come from the checkout (zarrs requires zarr, so a broken version lookup would install zarr from PyPI). Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Check zarr comes from the checkout's src/ by resolved path rather than by string prefix, and before importing the tests. Narrow the suite's note on which packages read device arrays directly. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e only numcodecs codecs and zarrs read device arrays directly, which fails on CuPy whatever zarr does, and the fake device array would let them pass. Run those cases, and imagecodecs' numcodecs codecs, with a host prototype only, as test_buffer_prototype.py now does for numcodecs. Share the unusable-config directions through buffer_kinds.py, and check the array and store buffer kinds in the no-config test too. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d-v-b
force-pushed
the
claude/third-party-codec-prototype
branch
from
November 30, 2026 12:29
593dfe8 to
5066305
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Adds a test suite that runs codec packages from outside zarr (imagecodecs, numcodecs' pcodec and zfpy codecs, and the zarrs-python codec pipeline) through reads and writes whose
BufferPrototypediffers from the buffer kindzarr.confignames. The packages stay out of the default test environments; athird-party-codecshatch environment,just third-party-codecs, and a CI job install and run them.Stack: this PR sits on #474 (
claude/silly-wozniak-87525b, codecs use the prototype they are given), which must merge first; this one stays a draft until then. It has no changelog fragment: it changes tests and CI only.What the suite runs
tests/test_codecs/test_third_party_codecs.pyhas two tests over the same cases:test_third_party_codecs_use_the_given_prototype: a round trip (partial write into an absent chunk or shard, full write, partial write; full and partial read) in three directions: config names the fake device kind and the call asks for the CPU prototype; config names the CPU kind and the call asks for the device kind; both name the device kind. It checks the read result's array type, its values, and (forMemoryStore) the buffer type of every chunk value the store receives.test_third_party_codecs_read_no_buffer_config: the same round trip and checks withzarr.confignaming a buffer kind that cannot be built, with host and device prototypes. This catches zarr building a buffer fromzarr.configand converting it afterwards, which the first test cannot see.Cases that read device arrays directly (numcodecs codecs, including imagecodecs' numcodecs codecs on v2, and zarrs' Rust code) fail on CuPy whatever zarr does, and the fake device array, being host memory underneath, would let them pass. They run with a host prototype only, as #474's
test_buffer_prototype.pydoes for numcodecs. imagecodecs' zarr 3 codecs copy to the host themselves (as_numpy_array()) and run in every direction.imagecodecs-filters-compressorsimagecodecs.zarrDelta, Xor, Byteshuffle, Zstd, Lz4, Checksumimagecodecs-numcodecs(host only)imagecodecs.numcodecsDelta + Zstdimagecodecs-pcodec,-zfp(+Blosc2),-pngimagecodecs.zarrserializersnumcodecs-pcodec(host only)zarr.codecs.numcodecs.PCodec/numcodecs.PCodec(pcodec)numcodecs-zfpy(host only)zarr.codecs.numcodecs.ZFPY/numcodecs.ZFPY(zfpy, full precision)zarrs(host only)zarrs.ZarrsCodecPipeline(strict,LocalStore) with zarr's codecsThe fake device buffer kind, the directions (including the unusable-config ones), the recording store and the round trip moved from
test_buffer_prototype.pytotests/test_codecs/buffer_kinds.py;test_buffer_prototype.pycollects and passes the same 133 test IDs as on #474's branch (19c0986).round_tripnow casts its values to the array's data type (identical for int32).No package registers codecs through the
zarr.codecsentry-point group. imagecodecs registers its zarr 3 codecs withimagecodecs.zarr.register_codecs()(zarr.registry.register_codec), and zarrs registers azarr.codec_pipelineentry point.Per-package verdicts (local run, macOS arm64, Python 3.13)
Versions: imagecodecs 2026.11.11, pcodec 1.1.0, zfpy 1.0.1, zarrs 0.2.3, numcodecs 0.17.1, numpy 2.5.5. On #474's branch (19c0986), all 164 cases pass. On main (d06ed58) with the same test files, 96 fail.
chunk_spec.prototype.out.as_ndarray_like()from Rust.kvikio.zarr.GDSStore, a store, not a codec.kvikio-cu12does not build on macOS arm64, and no environment here installs it.No case fails only with the change.
Main's 96 failures, by error:
RuntimeError: a buffer / an array buffer was built from zarr.config(no-config test)ValueError: Non-default buffer prototypes are not supported within shards.(FusedCodecPipeline,src/zarr/codecs/sharding.py)TypeError: concatenate mixes host and device arrays(BatchedCodecPipeline shard assembly joining host index bytes to device chunk bytes)TypeError: a host buffer was given device memory(V2Codec /scatter_chunk)Installability and the CI job
uv pip compile --only-binary :all:): Python 3.12 and 3.13 resolve all four; on 3.14 zarrs has no wheels, so the env pins Python 3.13.import numcodecs(its version parse fails onpost0); Fix NumCodecs import with zfpy post-releases zarr-developers/numcodecs#893 fixes it. The env excludes that version.test.yml,third-party-codecs) first imports every package named by a case and asserts zarr comes from the checkout'ssrc/(zarrs requireszarr>=3.1, so a failed version lookup could install zarr from PyPI), then runs the suite. It is not in thetest-completegate: the packages float, so a third-party release could turn unrelated PRs red. Adding it to the gate, with pinned versions, is the maintainer's call.Limits
np.ndarraysubclass in host memory. NumPy calls refuse to mix it with host arrays, but C or Rust code that reads its buffer takes it as host memory. That is why numcodecs and zarrs cases run host-only; for imagecodecs' zarr 3 codecs the device directions show that zarr hands them the right kinds, not that they work on a GPU. A real-CuPy direction in the GPU job would close that.test_buffer_prototype.pycovers zarr's own paths more tightly. This suite's value is that it runs the packages' real codecs and pipeline API, so a zarr change those packages feel shows up here.Upstream issues found on the way
bytes; a second filter withshape/dtypeset refuses them (buf.shape=() does not match), andXorwithout them calls.tobytes()onbytes. Withoutshape,Delta.decodeon a 2-D chunk's flat buffer returns wrong values ([0,1,2,3] → [0,1,3,4]). All reproduce without zarr. The v2 case uses one filter withdtypeandshape.Adversarial review
Round 1 (two fresh reviewers, one on detection power with mutation tests, one on env/CI/layout); nothing serious.
CASES(648002e).src/(648002e).test-complete: left out, trade-off noted above.CodecPipelinecompatibility.Round 2 (fresh reviewer, fix diff only); nothing serious.
.../zarr-python-other; assertion ran after importing the tests: fixed in e6755b1 (resolved-pathis_relative_to, assertion first).Two consecutive rounds without a serious finding, so the review stopped there.
Round 3 (fresh reviewer, after the rebase onto #474: the host-only change and the move of #474's helpers); nothing serious.
test_buffer_prototype.pyruns the same test IDs with the same outcomes as fix(codecs): build buffers from the given prototype instead of zarr.config #474's; the moved code is byte-identical apart from renames.as_numpy_array(). Host-only cases still catch a numcodecs wrapper building fromzarr.config(6 failures)._cases: kept; a sharedDirection.on_hostwould tie the two, and can follow if the rule grows.Rebase onto 19c0986 (#474's final review fixes): mechanical, so no new review round. The moved fake device kind was diffed against #474's (identical after the
as_array_like()warning checks, 5066305); the movedtest_buffer_prototype.pycollects the same 133 test IDs as #474's and all pass; main's verdicts are unchanged.🤖 Generated with Claude Code