zarr-developers / zarr-python

An implementation of chunked, compressed, N-dimensional arrays for Python.
https://zarr.readthedocs.io
MIT License
1.51k stars 280 forks source link

What is the abstract `ArrayMetadata` class for #2300

Open d-v-b opened 4 weeks ago

d-v-b commented 4 weeks ago

Can someone explain why we need an abstract base class for array metadata, as opposed to handling the union of the two distinct v2 array metadata and v3 array metadata classes?

I'm asking for academic reasons, because the things we are modelling (zarr metadata documents) are not, in fact, hierarchically related, and we don't anticipate any new metadata documents coming on the scene any time soon. Modelling two similar, but importantly distinct entities as a union seems simpler to me than imposing a common API atop them.

I'm also asking for practical reasons, because I have a forthcoming PR where I have to prune a property off the ArrayMetadata abc to accurately model v2 metadata, and it made me wonder how load bearing that abc really is.

TomAugspurger commented 4 weeks ago

as opposed to handling the union of the two distinct v2 array metadata and v3 array metadata classes?

FWIW, I've wondered the same thing :)

I think that defining ArrayMetadata = ArrayV2Metadata | ArrayV3Metadata is simpler and lets us write code that's generic over the zarr format equally well.