BUG: Fix empty Group nodes lacking a "consolidated_metadata" field#3967
Open
TomAugspurger wants to merge 2 commits into
Open
BUG: Fix empty Group nodes lacking a "consolidated_metadata" field#3967TomAugspurger wants to merge 2 commits into
TomAugspurger wants to merge 2 commits into
Conversation
All nodes opened via `open_consolidated` are expected to have a non-null `.metadata.consolidated_metadata`. zarr-developers#3954 showed an example, with a data file written by zarr-python 2.x, where that condition failed to hold. This happened because of a slight difference between how zarr-python 3.x writes consolidated metadata and how zarr-python 2.x wrote it. For leaf `Group` nodes (a `Group` with no `Group` or `Array` children), zarr-python 3.x includes an "empty" `consolidated_metadata` field. In zarr-python 3.x, we include a `consolidated_metadata: metadata: {}` field to indicate that it's empty. zarr-python 2.x *didn't* include that. The fix is to update how we load this type of data. We effectively normalize a node missing consolidated metadata to one that is known not to have consolidated metadata (which is consistent with the idea behind consolidated metadata: just do one metadata read up front).
TomAugspurger
commented
May 12, 2026
Comment on lines
+277
to
+278
| if isinstance(child, GroupMetadata) and child.consolidated_metadata is None: | ||
| child = replace(child, consolidated_metadata=ConsolidatedMetadata(metadata={})) |
Contributor
Author
There was a problem hiding this comment.
This is the new bit. The rest is rewriting the dic comprehension to a for loop.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3967 +/- ##
=======================================
Coverage 93.27% 93.28%
=======================================
Files 87 87
Lines 11739 11745 +6
=======================================
+ Hits 10950 10956 +6
Misses 789 789
🚀 New features to boost your workflow:
|
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.
All nodes opened via
open_consolidatedare expected to have a non-null.metadata.consolidated_metadata. #3954 showed an example, with a data file written by zarr-python 2.x, where that condition failed to hold.This happened because of a slight difference between how zarr-python 3.x writes consolidated metadata and how zarr-python 2.x wrote it. For leaf
Groupnodes (aGroupwith noGrouporArraychildren), zarr-python 3.x includes an "empty"consolidated_metadatafield. In zarr-python 3.x, we include aconsolidated_metadata: metadata: {}field to indicate that it's empty. zarr-python 2.x didn't include that.The fix is to update how we load this type of data. We effectively normalize a node missing consolidated metadata to one that is known not to have consolidated metadata (which is consistent with the idea behind consolidated metadata: just do one metadata read up front).
Closes #3954
TODO:
docs/user-guide/*.mdchanges/