-
-
Notifications
You must be signed in to change notification settings - Fork 365
Feat/store paths #2272
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
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.
| 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?
| 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.
| 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:
|
I didn't see this before, but note that neuroglancer (and soon tensorstore) use the syntax:
not
Regarding According to https://en.wikipedia.org/wiki/File_URI_scheme it is supposed to be either I should probably fix tensorstore to accept either form. For both tensorstore and zarr-python allowing |
| def __str__(self) -> str: | ||
| return f"zip://{self.path}" | ||
| # lets try https://github.com/zarr-developers/zeps/pull/48/files | ||
| return f"file:///{self.file_path}|zip://{self.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 think you have too many slashes after file: because file_path also starts with a slash, right?
Also you should percent-encode both file_path and path for consistency with my ZEP proposal and tensorstore, and to avoid ambiguity since | is a legal path character except on Windows.
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 catching this!
Adds a
pathattribute to all the store classes. Key operations likeget,set,list,list_prefixetc are now scoped to the subtree rooted by thepathattribute of the store, which is howRemoteStoreworks in the v3 branch. This change is motivated by the desire for a consistent, scalable store API.Key changes:
LocalStore.roottoLocalStore.path, and changed the type of the attribute frompathlib.Pathtostrpathattribute toMemoryStorepathattribute ofZipStore, and introduced a new attributefile_paththat does whatZipStore.pathused to do (point to the location of the Zipfile in the parent file system).TODO: