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
{{ message }}
Repository navigation
zarr.core.Array.chunk_store changes type after zarr=2.23.3 (after PR 1304) #1362
Hey guys, just a heads up that the chunk_store object resulted from calling the chunk_store() method on a Zarr array changes type for objects (Zarr arrays) created from loading files with fsspec after zarr=2.13.3, ie after PR #1304 was merged:
with 2.13.3 my chunk_store (see below for reproducible code) is KVStore: <fsspec.mapping.FSMap object at 0x7feba08afee0> at 0x7feba08aff40>
with 2.13.6 same chunk_store object is <zarr.storage.FSStore object at 0x7fd3ea52bf40>
This causes issues when one wants to call properties of the KVStore object like _mutable_mapping - if this is intended please provide both a mention in the release notes (as a breaking change) and a solution how to still be able to use _mutable_mapping, if it's a bug - then you know what to do 😁 🍺
Here's my minimal code - like super minimal 😁 - and kudos to Zarr for preserving structure in such a Null case
Hi @valeriupredoi - thanks for reporting this potential bug! It looks like #1304 may have caused more problems than it fixed. 🤦
We'd love to be able to act on this, but I would really like to first encourage you to make your bug report more minimal. It would be great if you could remove the references to kerchunk, local file paths, etc. in your example. Here is a great guide for how to do this.
@rabernat cheers muchly! Absolutely, will do that in a sec - for now we've pinned zarr so no rush at our end, but will try minimize the test for you guys to be able to reproduce the issue w/o extra dependencies and stuff 🍺
@rabernat I have now edited the minimal test case - my apologies, I didn't know Zarr is so flexible so that it really doesn't need any data whatsoever (all can be mocked), with the functional types and structure still preserved - well done! 🍻
hi @rabernat apols, I mentioned in the description but it's not clear - you'll have to create an empty test.json ie empty by JSON standards, just add {} in the file 👍
Indeed that should work! I tried the code in your previous comment (whereby the json file is constructed with the context manager and that worked for me...), but that's true, I don't think one needs the ref FS
Now, can you help me understand what exactly is the problem? The FSMap has correctly been promoted to an FSStore. This object will give much better performance on concurrent read / write operations, as discussed in #1296.
Can you explain why the FSStore object is problematic for you?
Ok, glad we found a truly minimum reproducer! blush
and a really nice proof Zarr supports Null testing nicely 😁
Can you explain why the FSStore object is problematic for you?
We are treating and using chunk_store as a KVStore so we are using one of its methods _mutable_mapping, which is no longer an attribute of it anymore, see eg test fail: AttributeError: 'FSStore' object has no attribute '_mutable_mapping' - I didn't know this change was as per intended, and it'd be nice if this was communicated in the release notes/changelog together with a suggestion how to transfer to new method/API
In general, FSStore and FSMap implement a very similar public interface. They are both MutableMappings, so you can treat them as dictionaries and use getitem / setitem syntax on them. FSStore has a few public methods that FSMap does not, like getitems and setitems.
we are using one of its methods _mutable_mapping,
._mutable_mapping is a private attribute. As developers, we do not make any guarantees about the stability of private attributes. They may change or disappear at any time. So I would suggest that you do not rely on them in your user code.
Can you explain why you were using the _mutable_mapping attribute? Maybe we can find a workaround.
@rabernat that's a very good question - as I understand it, we use it to get the mapping of the input netCDF4 files we input onto the Zarr format, so a full image of the data and metadata as Zarr would see it:
ie the FS reference for the file. My colleague @bnlawrence can tell you more since he's implemented this method, but that should be the gist of it. If there is any way to grab this dictionary from FSStore, then we'd gladly use that, especially if that was a public function 👍
You should be able to access the underlying fsspec filesystem object via the .fs attribute of the FSStore object. So zarr_group.chunk_store.fs.references should work.
Ah sorry @rabernat, @valeriupredoi has just pointed this thread out to me - I have to admit to mostly silencing my github notifications as I can't cope with the information onslaught.
For what it's worth, this is part of building a tool to allow the file system (or the S3 server) to do basic reductions on chunks rather than do full chunk loads (to avoid data movement). We have four pieces in flight at the moment: a Python client application (cf-python of course), some Python middleware (that uses this piece of the zarr ecosystem), a Posix server, and an S3 proxy server ... but until we put them all together (due in Q2/Q3 this year), there's not much to show or talk about.
We absolutely intend the middleware to be reusable by any client application/library (including xarray), but until we have it working enough (i.e. with the storage clients as well) to sell the idea, we're not talking much :-)
Thanks for referring to my proposal @rabernat ! @bnlawrence , this proposal introduces a small and adjustable extra storage, but should make the large-volume data reduction/aggregation service much faster and cheaper since we only need to extract the chunks at the boundary. If this appears to be related to what you are trying to achieve, feel free to join the Zarr community call next Wed when I plan to have a walkthrough on this. Thanks!
Our approach is to push the computation of partial sums etc into the storage itself (which has plenty of compute for such tasks, given that it can do erasure coding etc). What is probably in common with our two approaches is how we would want to tell Dask when it can avoid having to do these calculations itself. @valeriupredoi Perhaps you or @davidhassell could see if you can join that call? If not, maybe we can set something specific up for a conversation - it is a bit niche :-)
Our approach is to push the computation of partial sums etc into the storage itself (which has plenty of compute for such tasks, given that it can do erasure coding etc). What is probably in common with our two approaches is how we would want to tell Dask when it can avoid having to do these calculations itself. @valeriupredoi Perhaps you or @davidhassell could see if you can join that call? If not, maybe we can set something specific up for a conversation - it is a bit niche :-)
Thanks for your info @bnlawrence ! Yes, there may be something in common between our approaches (at least it looks like we are trying to achieve similar goal:) Do you happen to have any links/resources describing more about your approach?
Activity
rabernat commentedon Mar 6, 2023
Hi @valeriupredoi - thanks for reporting this potential bug! It looks like #1304 may have caused more problems than it fixed. 🤦
We'd love to be able to act on this, but I would really like to first encourage you to make your bug report more minimal. It would be great if you could remove the references to kerchunk, local file paths, etc. in your example. Here is a great guide for how to do this.
valeriupredoi commentedon Mar 6, 2023
@rabernat cheers muchly! Absolutely, will do that in a sec - for now we've pinned zarr so no rush at our end, but will try minimize the test for you guys to be able to reproduce the issue w/o extra dependencies and stuff 🍺
valeriupredoi commentedon Mar 6, 2023
@rabernat I have now edited the minimal test case - my apologies, I didn't know Zarr is so flexible so that it really doesn't need any data whatsoever (all can be mocked), with the functional types and structure still preserved - well done! 🍻
rabernat commentedon Mar 6, 2023
Hi @valeriupredoi - thanks for updating your example! However, it is still not reproducible.
When I tried to run your code, I got the following error:
valeriupredoi commentedon Mar 6, 2023
hi @rabernat apols, I mentioned in the description but it's not clear - you'll have to create an empty
test.jsonie empty by JSON standards, just add{}in the file 👍rabernat commentedon Mar 6, 2023
I tried this:
And got the following error:
rabernat commentedon Mar 6, 2023
Does this example really need the reference filesystem? Here is one without it
Does this reproduce the problem?
valeriupredoi commentedon Mar 6, 2023
Indeed that should work! I tried the code in your previous comment (whereby the json file is constructed with the context manager and that worked for me...), but that's true, I don't think one needs the ref FS
rabernat commentedon Mar 6, 2023
Ok, glad we found a truly minimum reproducer! 😊
Now, can you help me understand what exactly is the problem? The
FSMaphas correctly been promoted to anFSStore. This object will give much better performance on concurrent read / write operations, as discussed in #1296.Can you explain why the
FSStoreobject is problematic for you?valeriupredoi commentedon Mar 6, 2023
and a really nice proof Zarr supports Null testing nicely 😁
We are treating and using
chunk_storeas aKVStoreso we are using one of its methods_mutable_mapping, which is no longer an attribute of it anymore, see eg test fail:AttributeError: 'FSStore' object has no attribute '_mutable_mapping'- I didn't know this change was as per intended, and it'd be nice if this was communicated in the release notes/changelog together with a suggestion how to transfer to new method/APIrabernat commentedon Mar 6, 2023
Ok I understand. Thanks for re-explaining!
In general,
FSStoreandFSMapimplement a very similar public interface. They are both MutableMappings, so you can treat them as dictionaries and use getitem / setitem syntax on them. FSStore has a few public methods that FSMap does not, likegetitemsandsetitems.._mutable_mappingis a private attribute. As developers, we do not make any guarantees about the stability of private attributes. They may change or disappear at any time. So I would suggest that you do not rely on them in your user code.Can you explain why you were using the
_mutable_mappingattribute? Maybe we can find a workaround.valeriupredoi commentedon Mar 6, 2023
@rabernat that's a very good question - as I understand it, we use it to get the mapping of the input netCDF4 files we input onto the Zarr format, so a full image of the data and metadata as Zarr would see it:
where
self.zdsis a Zarr array -ie the FS reference for the file. My colleague @bnlawrence can tell you more since he's implemented this method, but that should be the gist of it. If there is any way to grab this dictionary from FSStore, then we'd gladly use that, especially if that was a public function 👍
rabernat commentedon Mar 6, 2023
You should be able to access the underlying fsspec filesystem object via the
.fsattribute of theFSStoreobject. Sozarr_group.chunk_store.fs.referencesshould work.Looking at the source code is probably helpful:
zarr-python/zarr/storage.py
Line 1278 in 5ece3e6
👋 @bnlawrence! Lovely to see you around these parts. I'd love to learn what you are up to and how we might collaborate around Zarr / kerchunk / etc.
valeriupredoi commentedon Mar 6, 2023
cheers @rabernat - I'll have a look, many thanks for your help so far 🍺
valeriupredoi commentedon Mar 6, 2023
whoa! Proves out in the new configuration one doesn't need to access the
_mutable_mappingmethod after all, this does it perfectly:Cheers, @rabernat 🍺 I'll keep this open if you'd still need it for bookkeeping and/or @bnlawrence's reply 😁
rabernat commentedon Mar 6, 2023
We can close the issue but feel free to keep the conversation going!
bnlawrence commentedon Mar 17, 2023
Ah sorry @rabernat, @valeriupredoi has just pointed this thread out to me - I have to admit to mostly silencing my github notifications as I can't cope with the information onslaught.
For what it's worth, this is part of building a tool to allow the file system (or the S3 server) to do basic reductions on chunks rather than do full chunk loads (to avoid data movement). We have four pieces in flight at the moment: a Python client application (cf-python of course), some Python middleware (that uses this piece of the zarr ecosystem), a Posix server, and an S3 proxy server ... but until we put them all together (due in Q2/Q3 this year), there's not much to show or talk about.
We absolutely intend the middleware to be reusable by any client application/library (including xarray), but until we have it working enough (i.e. with the storage clients as well) to sell the idea, we're not talking much :-)
rabernat commentedon Mar 17, 2023
Very interesting. I would check out https://zarr.dev/zeps/draft/ZEP0005.html, by @hailiangzhang and colleagues at NASA Goddard. It aims to accomplish a very similar thing via a Zarr spec extension. Discussion at zarr-developers/zarr-specs#205
hailiangzhang commentedon Mar 17, 2023
Thanks for referring to my proposal @rabernat !
@bnlawrence , this proposal introduces a small and adjustable extra storage, but should make the large-volume data reduction/aggregation service much faster and cheaper since we only need to extract the chunks at the boundary. If this appears to be related to what you are trying to achieve, feel free to join the Zarr community call next Wed when I plan to have a walkthrough on this. Thanks!
bnlawrence commentedon Mar 18, 2023
Our approach is to push the computation of partial sums etc into the storage itself (which has plenty of compute for such tasks, given that it can do erasure coding etc). What is probably in common with our two approaches is how we would want to tell Dask when it can avoid having to do these calculations itself. @valeriupredoi Perhaps you or @davidhassell could see if you can join that call? If not, maybe we can set something specific up for a conversation - it is a bit niche :-)
hailiangzhang commentedon Mar 18, 2023
Thanks for your info @bnlawrence ! Yes, there may be something in common between our approaches (at least it looks like we are trying to achieve similar goal:) Do you happen to have any links/resources describing more about your approach?