-
-
Notifications
You must be signed in to change notification settings - Fork 308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle fsspec.FSMap using FSStore store #1304
Conversation
80d4d63
to
07e2be1
Compare
Codecov Report
@@ Coverage Diff @@
## main #1304 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 35 35
Lines 14130 14148 +18
=========================================
+ Hits 14130 14148 +18
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In principle this can be OK, but please see my major comment.
I wonder why this is necessary? Currently the FSMap will be wrapped by KVStore and everything works fine.
zarr/_storage/v3.py
Outdated
check=store.check, | ||
create=store.create, | ||
missing_exceptions=store.missing_exceptions, | ||
**(storage_options or {})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point, we switch from the already configured Map and internal FS instance we were given to making new instances with these storage_options, which will in general be different. This is missed in the test, which uses the local filesystem and needs no kwargs.
(same for the other copy of this call below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point, we switch from the already configured Map and internal FS instance we were given to making new instances with these storage_options, which will in general be different. This is missed in the test, which uses the local filesystem and needs no kwargs.
@martindurant what's your recommendation?
@martindurant see #1296. afaiu an alternative to this could be to add set/get items to |
Ah I see, so previous store.getitems existed, but not when wrapped. So doing what this PR does is worthwhile, but my comment still needs to be solved. Can we have FSStore accept an FSMap instance as an alternative to creating one? |
@martindurant I don't have a strong opinion about this, but want to point out that right now |
OK, so we should pass (mapper.root, fs=mapper.fs), right? |
I mean the point is, not to pass the storage_options. Maybe it makes no difference, so sorry if I am just confusing things! |
OK, I guess you would hit https://github.com/zarr-developers/zarr-python/pull/1304/files#diff-565e487a2f60258b6baa2e4db8ef175cc16b8a949651834bd43d0a9f21e07358R1342 if you tried, never mind... |
@martindurant sorry, that link above doesn't resolve for me, you probably mean this: Lines 1329 to 1331 in 1af77b6
So it's not possible to pass both |
Yes that's the one +1 |
The use case here is that many users (e.g. @ravwojdyla, others in the Pangeosphere) are used to constructing stores via I support this PR in general because it seems like a lightweight way of upgrading an FSSMap to an FSStore. An alternative would be to bring FSMap into feature parity with FSStore. |
07e2be1
to
81201a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this @ravwojdyla! I see no major issues, just one small suggestion regarding coverage.
check=store.check, | ||
create=store.create, | ||
missing_exceptions=store.missing_exceptions, | ||
**(storage_options or {})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's actually fine to pass storage_options
through like this. If it is not empty, it will trigger an error via
Lines 1329 to 1331 in 1af77b6
else: | |
if storage_options: | |
raise ValueError("Cannot specify both fs and storage_options") |
This is the desired behavior. Storage options will already be configured on the FSMap
, so specifying them twice would not make sense.
81201a3
to
3c173f9
Compare
@martindurant, are all your concerns addressed? From my side, I do start to wonder just looking at the changes needed if fsspec isn't starting to become more than an optional dependency. |
To be sure, fsspec is a very small dep and one that has none of its own. I cannot make that decision, however. Yes, I am happy otherwise. |
👍 to making fsspec a required dependency. However, let's address that in a separate PR. This is @ravwojdyla's first contribution to Zarr, so let's keep it simple. @ravwojdyla - I invite you to give yourself appropriate credit for this bug fix in |
979906d
to
3a9fab9
Compare
🎉 Thanks, @ravwojdyla 🙏🏽 |
Re: #1296
TODO:
Add docstrings and API docs for any new/modified user-facing classes and functionsNew/modified features documented in docs/tutorial.rstChanges documented in docs/release.rst