Skip to content

FSStore with simplecache fails on missing chunks #1363

Description

@fwrite

Zarr version

v2.14.2

Numcodecs version

v0.11.0

Python Version

v3.8.10

Operating System

Linux (Google Colab)

Installation

Google Colab (!pip install --upgrade zarr xarray fsspec aiohttp)

Description

When accessing a sparse zarr Array over HTTP missing chunks are handled inconsistently with and without simplecache. When simplecache is chained into the zarr.storage.FSStore missing files (HTTP 404) raise a KeyError, instead of being filled with the fill_value.

This behaviour extends to popular access methods, such as xarry.open_zarr().

Unfortunately, the apparent change in behaviour coincides with a revised structure on my side. Therefore, I am unsure on when the bug (first) occurred or if this configuration ever worked.

Steps to reproduce

A query along the first axis without simplecache works:

z = zarr.convenience.open_consolidated('https://geotiles.nl/cube.zarr')
z['S2']['R051']['B04'][:, -1, -1]

With simplecache, it fails:

z = zarr.convenience.open_consolidated('simplecache::https://geotiles.nl/cube.zarr')
z['S2']['R051']['B04'][:, -1, -1]

as fsspec fails to identify the missing key as empty chunk:

---------------------------------------------------------------------------

FileNotFoundError                         Traceback (most recent call last)

[/usr/local/lib/python3.8/dist-packages/fsspec/mapping.py](https://localhost:8080/#) in getitems(self, keys, on_error)
     92         try:
---> 93             out = self.fs.cat(keys2, on_error=oe)
     94             if isinstance(out, bytes):

40 frames

FileNotFoundError: https://geotiles.nl/cube.zarr/S2/R051/B04/343.10.11


The above exception was the direct cause of the following exception:

KeyError                                  Traceback (most recent call last)

[/usr/local/lib/python3.8/dist-packages/fsspec/mapping.py](https://localhost:8080/#) in getitems(self, keys, on_error)
     95                 out = {keys2[0]: out}
     96         except self.missing_exceptions as e:
---> 97             raise KeyError from e
     98         out = {
     99             k: (KeyError() if isinstance(v, self.missing_exceptions) else v)

KeyError:

Additional output

Explicitly mentioning FileNotFoundError in the list of missing_exception of zarr.storage.FSStore() has no effect.

z = zarr.convenience.open_consolidated(zarr.storage.FSStore('simplecache::https://geotiles.nl/cube.zarr', normalize_keys=False, mode='r', missing_exceptions=(FileNotFoundError,)))
z['S2']['R051']['B04'][:, -1, -1]
---------------------------------------------------------------------------

FileNotFoundError                         Traceback (most recent call last)

[/usr/local/lib/python3.8/dist-packages/fsspec/mapping.py](https://localhost:8080/#) in getitems(self, keys, on_error)
     92         try:
---> 93             out = self.fs.cat(keys2, on_error=oe)
     94             if isinstance(out, bytes):

17 frames

FileNotFoundError: https://geotiles.nl/cube.zarr/S2/R051/B04/343.10.11


The above exception was the direct cause of the following exception:

KeyError                                  Traceback (most recent call last)

[/usr/local/lib/python3.8/dist-packages/fsspec/mapping.py](https://localhost:8080/#) in getitems(self, keys, on_error)
     95                 out = {keys2[0]: out}
     96         except self.missing_exceptions as e:
---> 97             raise KeyError from e
     98         out = {
     99             k: (KeyError() if isinstance(v, self.missing_exceptions) else v)

KeyError:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPotential issues with the zarr-python library

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions