Skip to content

treat codec classes as part of the array configuration #3854

@d-v-b

Description

@d-v-b

When reading array metadata documents, we have to map the contents of the data_type and codecs fields to python objects that comprise the in-memory model of a data type and a codec. We do this today with a global configuration object that stores data types and codecs in registries.

Codecs do compute, and not every codec implementation is the same. That means users might want to compare different codec implementations with the same array data. We don't have an easy path for this today -- you have to open the first array, update the registry, then open the second array.

A better approach would be to treat the set of available codec classes as part of the array's runtime configuration. E.g.,

arr = open_array(..., config={"codec_classes": {"gzip": zarr.codecs.GZipCodec ...}})
# same array, different codec implementation of gzip codec
arr_with_other_gzip = arr.with_config({"codec_classes": {**arr.config.codec_classes, "gzip": mylib.Gzip}}

If "codec_classes" is not specified in the config, then values are retrieved from the global configuration. A nice side-effect of this approach is that we remove a direct dependency between array internals and the mutable, global config. Instead, those same array internals depend on an immutable, array-scoped piece of data (the config object).

We should probably take the same approach for the codec pipeline class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions