Uh oh!
There was an error while loading. Please reload this page.
Allow mode casting for Stores - #2249
Conversation
| return True | ||
| def with_mode(self, mode: ZipStoreAccessModeLiteral) -> Self: # type: ignore[override] | ||
| return type(self)( |
There was a problem hiding this comment.
This probably needs some work... would we want the new Store to share the same Lock?
There was a problem hiding this comment.
This wasn't straightforward to implement, because of a need to close the old ZipStore (and writing the ending records) before opening the new store.
For now I've opted to raise NotImplementedError for ZipStore.
Uh oh!
There was an error while loading. Please reload this page.
StoresStoresThe GPU test failed. I think that's because at zarr-python/src/zarr/store/memory.py Lines 170 to 171 in 692593b store.with_mode('r') no longer views the same dict as the first store.@akshaysubr I suspect that those lines are there to ensure that all of the values in the dictionary are GPU buffers. What do you think about documenting that as a requirement to use the store (and maybe narrowing the type of the dict values in |
jhamman
left a comment
There was a problem hiding this comment.
Thanks @TomAugspurger -- a few suggestions but this is great.
cc @d-v-b who was also looking at this problem today.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
d-v-b
commented
Sep 26, 2024
second this, once those suggestions are integrated then I think this will be a great addition. |
Uh oh!
There was an error while loading. Please reload this page.
TomAugspurger
commented
Sep 26, 2024
It's tangentially related, but I wanted to confirm that people are OK with changing the |
Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
jhamman
commented
Sep 27, 2024
cc @akshaysubr |
jhamman
left a comment
There was a problem hiding this comment.
This looks good to me @TomAugspurger - some failing tests in GPU land but otherwise looks good to me.
| return f"GpuMemoryStore({str(self)!r})" | ||
| @classmethod | ||
| def from_dict(cls, store_dict: MutableMapping[str, Buffer]) -> Self: |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
jhamman
commented
Sep 27, 2024
pre-commit.ci autofix |
Following the discussion in #2186 (comment), this is a POC for opening "reopening" a store with a new mode.
The semantics are that reopening a store with a new mode should return a new Store that's backed by the same underlying data.
AFAICT, our current stores use / enforce
mode"logically". There's nothing about the actual underlying store that's readonly whenmode="r". You could imagine some cases where it's not possible to cast between modes (e.g. you have a readonly database connection). I think it's fine for those Stores to handle that.By default, the method is abstract meaning this is a new bit of code required for stores to implement. We could also raise
NotImplementedErrorby default.TODO: