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 have successfully used the Zarr LRU cache with Xarray. You just have to initialize the Store object outside of Xarray and then pass it to open_zarr or open_dataset(store, engine="zarr").
Glad you got it working! So you're saying it does not work with open_zarr and does work with open_dataset(...engine='zarr')? Weird. We should deprecate open_zarr.
However, the behavior in Dask is strange. I think it is making each worker have its own cache and blowing up memory if I ask for a large cache.
Yes, I think I experienced that as well. I think the entire cache is serialized and passed around between workers.
I couldn't get open_zarr to open without Daskifying arrays. open_dataset(..., engine="zarr") does open without Daskifying when you haven't passed chunks.
I am working on a project where caching would be highly desirable. Version 3.0 of Zarr-Python does not contain LRUStoreCache anymore. Any idea on how caching to disk could now be implemented?
Activity
rabernat commentedon Mar 14, 2019
Or should we use xarray's own caching mechanism?
rabernat commentedon Mar 14, 2019
I have created two PRs which attempt to provide zarr caching in different ways. I would welcome some advice on which one is a better approach.
tasansal commentedon Sep 12, 2022
Hi @rabernat, I looked at your PRs, and they seem to haven't gotten much attention.
I tried using a store with LRUCache in
open_zarr, but it appears to ignore the cache.For our use cases in https://github.com/TGSAI/mdio-python, we usually want to use any form of LRUCache (it doesn't have to be Zarr's necessarily).
rabernat commentedon Sep 12, 2022
I have successfully used the Zarr LRU cache with Xarray. You just have to initialize the Store object outside of Xarray and then pass it to
open_zarroropen_dataset(store, engine="zarr").Have you tried that?
dcherian commentedon Sep 12, 2022
This would be good to document!
tasansal commentedon Sep 13, 2022
@rabernat, yes, I have tried that like this:
When I read the same data twice, it still downloads. Am I doing something wrong?
While I wait for a response, I will try it again and update if it works, but the last time I checked, it didn't.
Note to self: I also need to check it with Zarr backend and Dask backend.
tasansal commentedon Sep 13, 2022
@rabernat
Following up on the previous, yes it does work with the Zarr backend! I agree with @dcherian, we should add this to the docs.
However, the behavior in Dask is strange. I think it is making each worker have its own cache and blowing up memory if I ask for a large cache.
dcherian commentedon Sep 13, 2022
@tasansal a PR would be very welcome!
rabernat commentedon Sep 13, 2022
Glad you got it working! So you're saying it does not work with
open_zarrand does work withopen_dataset(...engine='zarr')? Weird. We should deprecateopen_zarr.Yes, I think I experienced that as well. I think the entire cache is serialized and passed around between workers.
tasansal commentedon Sep 13, 2022
I couldn't get
open_zarrto open without Daskifying arrays.open_dataset(..., engine="zarr")does open without Daskifying when you haven't passed chunks.tasansal commentedon Sep 13, 2022
@dcherian, I will start a PR. Where do you think this belongs in the docs? Some places I can think of:
dcherian commentedon Sep 14, 2022
docs.xarray.dev/en/stable/user-guide/io.html seems great to me.
spmvoss commentedon May 19, 2025
I am working on a project where caching would be highly desirable. Version 3.0 of Zarr-Python does not contain LRUStoreCache anymore. Any idea on how caching to disk could now be implemented?