Skip to content

Conversation

@d-v-b
Copy link
Collaborator

@d-v-b d-v-b commented Dec 30, 2025

This PR allows the experimental V3 arrayspec and groupspec models to be constructed with extra keys, like consolidated_metadata. The requirement from the v3 spec is that arbitrary extra fields are permitted as long as they are named + config JSON objects objects with a "must_understand" field set to False.

@d-v-b
Copy link
Collaborator Author

d-v-b commented Jan 3, 2026

Updated this PR to only require that extra fields be objects with a must_understand: false key:value pair. Although the v3 spec requires a name field for extra keys, this is probably a regression that will get fixed as it breaks zarr-python's consolidated metadata implementation, so I'm not implementing that here.

xref zarr-developers/zarr-specs#371

RawFillValue = tuple[int, ...]

FillValue = BoolFillValue | IntFillValue | FloatFillValue | ComplexFillValue | RawFillValue | str
FillValue = object
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

for visibility @dstansby -- we will need to handle fill value validation on a per-datatype basis, because nearly anything can be a valid fill value for some data type. I made this change after expanding some tests and getting pydantic validation errors for some fill values for particular data types supported by zarr-python

Comment on lines +110 to +115
class AllowedExtraField(TypedDict):
"""
The type of additional fields that may be added to Zarr V3 Array or Group metadata documents.
"""

must_understand: Literal[False]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is weaker than what the spec currently requires, because the spec had a regression that hopefully gets fixed soon.

Extra fields must be dicts with a 'must_understand' key set to False.
"""
extra_checker.validate_python(self.__pydantic_extra__)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the recommended way to get type-checking for extra fields is to give the __pydantic_extra__ field an annotation in the class definition, but this broke due to a NameError during with type annotation resolution. chalking that up as a pydantic bug.

@d-v-b d-v-b merged commit 39e1445 into zarr-developers:main Jan 9, 2026
14 checks passed
@d-v-b d-v-b deleted the feat/consolidated-metadata branch January 9, 2026 20:40
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