Skip to content

Check if zarr store supports consolidated metadata #10457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

TomNicholas
Copy link
Member

@TomNicholas TomNicholas commented Jun 27, 2025

Needed to support the addition of .supports_consolidated_metadata in zarr-python upstream: zarr-developers/zarr-python#3119.

  • Closes #xxxx
  • Tests added
  • User visible changes (including notable bug fixes) are documented in whats-new.rst
  • New functions/methods are listed in api.rst

TomNicholas and others added 23 commits October 24, 2024 17:48
@@ -3744,6 +3746,29 @@ def test_chunk_key_encoding_v2(self) -> None:
assert actual["var1"].encoding["chunks"] == (2, 2)


class NoConsolidatedMetadataSupportStore(WrapperStore[Store]):
Copy link
Member Author

@TomNicholas TomNicholas Jun 27, 2025

Choose a reason for hiding this comment

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

TODO: I don't think I even want to try and define this class if zarr-python v3 is not installed

@@ -1768,6 +1768,10 @@ def _get_open_params(
else:
missing_exc = zarr.errors.GroupNotFoundError

if _zarr_v3():
if not store.supports_consolidated_metadata:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if not store.supports_consolidated_metadata:
if not getattr(store, "supports_consolidated_metadata", True):

I think this will be needed for Zarr >3.0.0,<3.1.0

Copy link
Member Author

Choose a reason for hiding this comment

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

Right - I had something like that then removed it 🤦

Copy link
Member Author

Choose a reason for hiding this comment

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

added in a47b2e2

@paraseba
Copy link

Thank you @maxrjones . Long term, I'd love to see the responsibility for managing the readonly flag removed from the abstract Store hierarchy. It feels this is a concern that is beyond what a Store should know about. It would help us keeping the Stores abstract and focused. Readonly-ness sounds like a session concern, independent of the details of how to write zarr objects to different media.

@TomNicholas
Copy link
Member Author

TomNicholas commented Jun 30, 2025

Thanks for the discussion everyone - I want to move any further discussion of this over to zarr-developers/zarr-python#3186, where I've raised @paraseba's suggestion as an issue.

For now I think I have what I need to be able to finish this PR.

@TomNicholas TomNicholas added the run-upstream Run upstream CI label Jul 1, 2025
@TomNicholas
Copy link
Member Author

TomNicholas commented Jul 1, 2025

So for this PR obviously there are failures here, but:

  • Upstream includes unreleased zarr data types changes, which will break a lot of things until @ianhi 's PR Updates for Zarr 3 Dtypes #10456 goes in - these are not needed for compatibility with zarr 3.0.9
  • Most of the failures are easy to fix (things like regexes getting differently-worded error messages than they expected) EDIT: Apparently @dcherian already fixed this one in main in Update error message regex for latest Zarr #10485, tracked by remove xfail on test_to_zarr_zip_store in test_backends_datatree #10486
  • I think the AttributeError: Can't get local object 'TestZarrNoConsolidatedMetadataSupport.create_zarr_target.<locals>.NoConsolidatedMetadataSupportStore' were caused by me hiding the definition of my test store in the test itself, and don't indicate a real bug EDIT: Defining it inside caused it to be unpickleable, which breaks some of the tests
  • There are still Store is not read-only but mode is 'r', for tests where we use ZipStore, because IIUC that does not implement .with_read_only. As this is a breaking change the only way to work around it would be to change xarray's tests to use a read-only zip store, and that should technically be done in a separate PR to this one. EDIT: See How to roundtrip to a ZipStore? zarr-developers/zarr-python#3194 and the temporary workaround remove xfail on test_to_zarr_zip_store in test_backends_datatree #10486
  • There is a failure where reading a non-consolidated store does not warn when it's expected to warn - I think that does indicate a logic bug in this PR for me to fix EDIT: addressed in 101b280, the test was expecting a warning that doesn't makes sense to be thrown for a store which does not support consolidated metadata

But that's it - then xarray should work with zarr 3.0.9 (and icechunk).

@TomNicholas
Copy link
Member Author

TomNicholas commented Jul 2, 2025

@TomNicholas TomNicholas enabled auto-merge (squash) July 2, 2025 19:53
@TomNicholas TomNicholas disabled auto-merge July 2, 2025 19:53
@TomNicholas TomNicholas merged commit ad25833 into pydata:main Jul 2, 2025
29 of 32 checks passed
@TomNicholas TomNicholas deleted the check_supports_consolidated_metadata branch July 2, 2025 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants