Skip to content

Conversation

@TomAugspurger
Copy link
Contributor

This refactors the interface of Codec.read and Codec.write to move from an Iterable[tuple[...] to an Iterable[BatchInfo].

Two things motivate this change

  1. Readability: I struggle to remember what the 4th member of these complex tuples. Having the name info.out_selection to remind me is helpful.
  2. Possible future-proofing: right now, any change to the interface is a hard break since the number of elements in the tuple will change. There may be a class of changes to the interface where we can add additional information to BatchInfo without breaking backwards compatibility.

I don't want to oversell motivation 2 though. If something is important enough to add to the interface, then presumably we expected implementations to, you know, use it.

@github-actions github-actions bot added the needs release notes Automatically applied to PRs which haven't added release notes label Dec 23, 2025
This refactors the interface of `Codec.read` and `Codec.write` to
move from an `Iterable[tuple[...]` to an `Iterable[BatchInfo]`.

Two things motivate this change

1. Readability: I struggle to remember what the 4th member of these
   complex tuples. Having the name `info.out_selection` to remind
   me is helpful.
2. Possible future-proofing: right now, any change to the interface
   is a hard break since the number of elements in the tuple will
   change. There may be a class of changes to the interface where
   we can add additional information to `BatchInfo` without breaking
   backwards compatibility.

I don't want to oversell motivaiton 2 though. If something is important
enough to add to the interface, then presumably we expectd implementations
to, you know, use it.
@TomAugspurger TomAugspurger force-pushed the tom/codec-pipeline-interface branch from a1ceba5 to 5fbad19 Compare December 23, 2025 16:09
@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

❌ Patch coverage is 44.44444% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.82%. Comparing base (b873691) to head (5fbad19).

Files with missing lines Patch % Lines
src/zarr/abc/codec.py 20.83% 19 Missing ⚠️
src/zarr/core/array.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3632      +/-   ##
==========================================
- Coverage   60.90%   60.82%   -0.08%     
==========================================
  Files          86       86              
  Lines       10174    10198      +24     
==========================================
+ Hits         6196     6203       +7     
- Misses       3978     3995      +17     
Files with missing lines Coverage Δ
src/zarr/codecs/sharding.py 62.10% <ø> (ø)
src/zarr/core/codec_pipeline.py 70.38% <100.00%> (+0.29%) ⬆️
src/zarr/core/array.py 68.48% <0.00%> (ø)
src/zarr/abc/codec.py 20.00% <20.83%> (+0.76%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs release notes Automatically applied to PRs which haven't added release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant