You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4e39185
Browse filesBrowse the repository at this point in the historyBrowse files
feat: name packages that provide a codec zarr cannot find
Closeszarr-developers#4271.
When zarr fails to resolve a codec it now says which Python packages are known to
provide it, instead of raising a bare KeyError holding only the codec name:
An implementation for codec 'wavpack' is not available. Register one explicitly
using the codec registry (see <docs>), or install a Python package that
registers a codec implementation with numcodecs. Known packages supporting this
codec: wavpack-numcodecs.
Two hand-maintained tables in zarr/registry.py hold the mapping, one per Zarr
format, because the two formats resolve codecs through different registries and the
same name can mean different things in each: `imagecodecs_*` names are declared by
`virtual-tiff` under the `zarr.codecs` entry point group and by
`imagecodecs-numcodecs` under `numcodecs.codecs`, and `crc32c` is a codec zarr
implements itself in format 3 while in format 2 it needs `numcodecs[crc32c]`. Each
table has an exact-match and a prefix-match half, since packages that provide many
codecs namespace them behind a shared prefix. Entries cover third-party packages and
the codecs numcodecs gates behind its own optional dependencies -- `zfpy`, `pcodec`,
`crc32c` and `msgpack2` -- which are the most common missing-codec case in practice.
Backwards compatibility: `get_codec_class` now raises `zarr.errors.UnknownCodecError`
instead of `KeyError`, both for a codec with no registered implementation and for a
codec whose configured implementation is not registered. `get_numcodec` raises it
instead of the ValueError numcodecs raises for an unregistered format 2 codec id.
All are subclasses of `ValueError`. Carrying the message on a `KeyError` was not an
option: `KeyError.__str__` reprs its argument, so a multi-sentence message comes back
quoted and escaped. `UnknownCodecError` is now exported from `zarr.errors`, since
users are being told to catch it.
`get_numcodec` supports numcodecs down to the declared 0.14 floor: `numcodecs.errors`
only exists from 0.15.1, so the unregistered-codec check prefers that exception type
where it is importable and falls back to matching the message otherwise.
Signed-off-by: arcusbuilds <[email protected]>
0 commit comments