-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
Feat/store paths #2272
base: main
Are you sure you want to change the base?
Feat/store paths #2272
Conversation
…nto feat/store-paths
…nto feat/store-paths
Edit: whoops, never mind. I missed that this only affects |
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 for working on this @d-v-b. I'm not 100% convinced the with_mode
approach is going to be substantially cleaner than our StorePath
right now but I'm curious to see how this plays out.
@@ -320,6 +336,13 @@ async def _get_many( | |||
for req in requests: | |||
yield (req[0], await self.get(*req)) | |||
|
|||
def with_path(self, path: str) -> Self: |
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.
def with_path(self, path: str) -> Self: | |
@abstractmethod | |
def with_path(self, path: str) -> Self: |
Or do you think think we can do this in a generic way that applies to all stores?
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 don't think we can make it generic unfortunately, because each store class might have its own extra attributes. maybe we could use __getstate__
to get around this?
src/zarr/store/memory.py
Outdated
@@ -28,12 +29,15 @@ def __init__( | |||
self, | |||
store_dict: MutableMapping[str, Buffer] | None = None, | |||
*, | |||
path: str = "", |
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.
this store highlights the fact that not all stores have a meaningful path
.
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'm not sure I agree -- if store_dict
really is an arbitrary mutable mapping, there's no guarantee that we want all IO operations to be scoped to the top-level key space, and that's exactly what the path
attribute is for.
src/zarr/store/zip.py
Outdated
file_path: Path | str, | ||
*, | ||
path: str = "", |
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.
This feels quite confusing. IIUC, you are allowing the caller to specify a path within the zipfile as opposed to putting the root of the store at the root of the zip, is that right?
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.
exactly! this is required to make ZipStore
congruent to RemoteStore
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.
though this may have some impact (simplifying) zarr-developers/zarr-specs#311
…of the path attribute
worth mentioning some changes to the reprs:
|
Adds a
path
attribute to all the store classes. Key operations likeget
,set
,list
,list_prefix
etc are now scoped to the subtree rooted by thepath
attribute of the store, which is howRemoteStore
works in the v3 branch. This change is motivated by the desire for a consistent, scalable store API.Key changes:
LocalStore.root
toLocalStore.path
, and changed the type of the attribute frompathlib.Path
tostr
path
attribute toMemoryStore
path
attribute ofZipStore
, and introduced a new attributefile_path
that does whatZipStore.path
used to do (point to the location of the Zipfile in the parent file system).TODO: