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
I want to preface this by saying that this would be a minor UX improvement. Not blocking at all!
Context
Zarr is extensible with custom codecs, e.g. imagecodecs. Naturally, this can lead to situations where the environment in which a Zarr archive was written is not the same as the environment in which a Zarr archive is read. This can lead to missing codecs when trying to load data from a Zarr archive.
Description
If you try to access a Zarr array that uses a codec which is not registered locally, a generic ValueError is thrown.
ValueError: codec not available: 'imagecodecs_jpeg2k'
In downstream libraries that use Zarr under the hood, this makes it harder to catch this specific error and to suggest an appropriate solution.
Instead, it would be great if a custom error is thrown that holds some additional information. For example
classInvalidCodecError(Exception):
"""Raised when an expected codec is not registered."""def__init__(self, codec_name: str):
self.codec_name=codec_namesuper().__init__(f"Codec not available: '{codec_name}'")
This would enable something like:
try:
arr=root["array"]
exceptInvalidCodecErroraserror:
iferror.codec_name=="imagecodecs_jpeg2k":
raiseRuntimeError("This Zarr archive requires `imagecodecs`, to install it use ...") fromerror
The text was updated successfully, but these errors were encountered:
I want to preface this by saying that this would be a minor UX improvement. Not blocking at all!
Context
Zarr is extensible with custom codecs, e.g.
imagecodecs
. Naturally, this can lead to situations where the environment in which a Zarr archive was written is not the same as the environment in which a Zarr archive is read. This can lead to missing codecs when trying to load data from a Zarr archive.Description
If you try to access a Zarr array that uses a codec which is not registered locally, a generic
ValueError
is thrown.In downstream libraries that use Zarr under the hood, this makes it harder to catch this specific error and to suggest an appropriate solution.
Instead, it would be great if a custom error is thrown that holds some additional information. For example
This would enable something like:
The text was updated successfully, but these errors were encountered: