fix: detect Zarr v3 format from store files#27
Merged
Conversation
Member
|
Thanks for fixing this! I decided to make the next radklim version as zarr3 too, and I just used your branch with: uvx --from "git+https://github.com/mlcast-community/mlcast-dataset-validator@fix/detect-zarr-v3-format" mlcast.validate_dataset source_data radar_precipitation data/dst/hourly/zarr/2001_2024.zarr |
leifdenby
requested changes
Feb 13, 2026
leifdenby
left a comment
Member
There was a problem hiding this comment.
Looks great! Just need a CHANGELOG update now
The previous approach used `getattr(ds, "zarr_format", 2)` which always defaulted to v2 because xarray does not expose `zarr_format` as a dataset attribute. This caused v3 stores to be misidentified as v2, incorrectly triggering the consolidated metadata check (which does not apply to Zarr v3). The new `_detect_zarr_format()` helper inspects the store on disk: Zarr v3 stores have a `zarr.json` at the root, while v2 stores have `.zgroup`. This works for both local and remote stores via fsspec.
franchg
force-pushed
the
fix/detect-zarr-v3-format
branch
from
February 13, 2026 14:33
b852b79 to
a0ac4d8
Compare
Member
Author
added! |
leifdenby
self-requested a review
February 13, 2026 16:12
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
getattr(ds, "zarr_format", 2), which always defaulted to v2 because xarray does not exposezarr_formatas a dataset attribute_detect_zarr_format()that inspects the store on disk: v3 stores havezarr.jsonat root, v2 stores have.zgroup. Works for both local and remote stores via fsspecConsiderations
I tested this on a zarr v3 and it works correctly. There is still the question if we want to enforce the presence of consolidated metadata also for zarr v3 altough it is currently an experimental feature and subject to change:
https://zarr.readthedocs.io/en/latest/user-guide/consolidated_metadata/