Skip to content

fix: detect Zarr v3 format from store files#27

Merged
franchg merged 1 commit into
mainfrom
fix/detect-zarr-v3-format
Feb 13, 2026
Merged

fix: detect Zarr v3 format from store files#27
franchg merged 1 commit into
mainfrom
fix/detect-zarr-v3-format

Conversation

@franchg

@franchg franchg commented Feb 13, 2026

Copy link
Copy Markdown
Member

Summary

  • The previous Zarr format detection relied on getattr(ds, "zarr_format", 2), which always defaulted to v2 because xarray does not expose zarr_format as a dataset attribute
  • Zarr v3 stores were misidentified as v2, incorrectly triggering the consolidated metadata check (which does not apply to v3)
  • Added _detect_zarr_format() that inspects the store on disk: v3 stores have zarr.json at root, v2 stores have .zgroup. Works for both local and remote stores via fsspec

Considerations

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/

@franchg
franchg requested a review from leifdenby February 13, 2026 05:35
@leifdenby

Copy link
Copy Markdown
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

and the validator now passes 🥳
Screenshot 2026-02-13 at 11 07 50

@leifdenby leifdenby left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
franchg force-pushed the fix/detect-zarr-v3-format branch from b852b79 to a0ac4d8 Compare February 13, 2026 14:33
@franchg

franchg commented Feb 13, 2026

Copy link
Copy Markdown
Member Author

Looks great! Just need a CHANGELOG update now

added!

@leifdenby
leifdenby self-requested a review February 13, 2026 16:12

@leifdenby leifdenby left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@franchg
franchg merged commit b50e303 into main Feb 13, 2026
3 checks passed
@franchg
franchg deleted the fix/detect-zarr-v3-format branch February 17, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants