From 5138727478f02ddb77779232f42b0443fbcb2ef8 Mon Sep 17 00:00:00 2001 From: kaczmarj Date: Mon, 10 Jul 2023 09:47:08 -0400 Subject: [PATCH] patch zarr to avoid decoding tiles in duplicate This implements the change proposed in https://github.com/zarr-developers/zarr-python/pull/1454 --- wsinfer/__init__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/wsinfer/__init__.py b/wsinfer/__init__.py index 5d16b3a..ba3471f 100644 --- a/wsinfer/__init__.py +++ b/wsinfer/__init__.py @@ -7,3 +7,18 @@ __version__ = _version.get_versions()["version"] del _version + + +# Patch Zarr. See: +# https://github.com/bayer-science-for-a-better-life/tiffslide/issues/72#issuecomment-1627918238 +# https://github.com/zarr-developers/zarr-python/pull/1454 +def _patch_zarr_kvstore(): + from zarr.storage import KVStore + + def _zarr_KVStore___contains__(self, key): + return key in self._mutable_mapping + + KVStore.__contains__ = _zarr_KVStore___contains__ + + +_patch_zarr_kvstore()