Repository navigation
Conversation
FrancescAlted
self-requested a review
October 22, 2026 12:04
FrancescAlted
left a comment
Member
There was a problem hiding this comment.
I like this PR. It is well-designed, effectively eliminates duplicate code between b2nd_to_zarr.py and zarr_to_b2nd.py, and maps Zarr shards →
b2nd chunks and Zarr inner chunks → b2nd blocks cleanly (great!). The test coverage is comprehensive too.
Some requests for improvements:
- Add
zarr-to-blosc2Alias in pyproject.toml - Include Blocks in
print_summary()(both in rich and text outputs) - Defensive Attribute Access on Zarr Arrays. In Zarr v2 array objects (e.g. if opened with older Zarr versions or custom store wrappers), .shards does not exist and raises
AttributeError. Similarly, Zarr v2 uses.compressor(singular) rather than.compressors. - Please use type annotation on output_path in zarr_to_b2nd (like
output_path: str | Path | None = None). - Warn on dropped attributes in verbose mode. Silently suppressing exceptions can lead to unexpected metadata loss (e.g. unstorable types). Suggestion: pass
verbose: bool = Falsetocopy_attrs()and emit a notification if an attribute cannot be stored.
Keep the good work!
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.
Summary
This PR adds a new command-line tool, zarr-to-b2nd, for converting Zarr arrays to Blosc2 .b2nd files. I created a file for utility functions shared between the b2nd-to-zarr and zarr-to-b2nd tools. The new tool works by determining the shape of the input in terms of the chunks and shards (if they exist) used in the Zarr dataset and its compression settings. Then data is copied in batches, sized by
--buffer-size. When shards are present in the Zarr dataset, shards become b2nd chunks and inner chunks become b2nd blocks. When shards are not present, Zarr chunks become b2nd chunks and the blocks are chosen by Blosc2.Closes #721. I plan to write docs in a separate PR for #714.
Changes
zarr_to_b2ndcommand registered in pyproject.toml--forceCompression handling
--codec/--clevel/--shuffleoverride all of the aboveTesting
I tested the utility on the 2-metre air temperature dataset from NOAA published as Zarr on AWS. It is a Zarr v2 dataset compressed with Blosc (lz4, level 9, shuffle) and carries attributes such as
units: "K"andlong_name.I downloaded the dataset with the following commands:
I tested the conversion utility with the following command and got these results:
Not included
AI tool usage
I used AI to make edits of the code and tests after I wrote an initial version. I have read through the code and understand how it works.