Skip to content

Commit

Permalink
add optional caching in open_zarr
Browse files Browse the repository at this point in the history
  • Loading branch information
floriankrb committed May 2, 2024
1 parent 4426fd7 commit 7961f16
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/anemoi/datasets/data/stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __contains__(self, key):
return key in self.store


def open_zarr(path, dont_fail=False):
def open_zarr(path, dont_fail=False, cache=None):
try:
store = path

Expand All @@ -117,6 +117,9 @@ def open_zarr(path, dont_fail=False):
store = zarr.storage.DirectoryStore(store)
store = DebugStore(store)

if cache is not None:
store = zarr.LRUStoreCache(store, max_size=cache)

return zarr.convenience.open(store, "r")
except zarr.errors.PathNotFoundError:
if not dont_fail:
Expand Down

0 comments on commit 7961f16

Please sign in to comment.