-
-
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
data wiped from MemoryStore
after store.close
+ array[:]
#2067
base: main
Are you sure you want to change the base?
Conversation
so i figured out where this is coming from. i'm not sure if it's a bug or not.
if not self._is_open:
await self._open()
I don't fully understand the open / closed semantics here. My intuition is that re-opening a closed store feels weird, and having the @brokkoli71 what's the logic for invoking |
tests are now passing with this PR. Instead of conditionally calling I think we should not merge this until we have a conversation about the store design. I would really like to be able to create store classes in synchronous code without needing @jhamman and @normanrz any thoughts about this issue (i.e., that we cannot fully initialize a store class in synchronous code without |
So is the bug here thati was reusing the array object I wrote to? But instead I should create a new one? |
The bug was that the store class self-destructs if a) it was created with |
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!
src/zarr/store/memory.py
Outdated
if not self._is_open: | ||
await self._open() | ||
raise RuntimeError("Store is closed. Cannot `get` from a closed store.") |
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.
turn this into self._check_open()
like self._check_writable()
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.
also, should we propagate this to all other 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.
both good ideas! the fact that tests passed without me making the last change means we need more tests for this
In this example the mode was explicitly set to
Furthermore, the examples in the docstrings of array.py suggest using The other problem with implicitly opening a store is a problem, too. I agree with the comments above. Edit:
I think it make sense here to fallback to |
Co-authored-by: Hannes Spitz <44113112+brokkoli71@users.noreply.github.com>
I had a similar thought process while working on #2000. On the one hand |
…nto indexing-after-close
@TomAugspurger do you have any ideas for how we could address this cleanly? for background, I am not happy with the solution I am pursuing in this PR, so we shouldn't give that much weight |
I don't have a strong opinion after thinking through this for a bit, but here's something: I wonder if we have two different kinds of "opening" (and closing) going on here:
IMO, the logical stuff should just happen the very first time a store is created using The resource-level stuff can happen whenever I think (perhaps with APIs for users to control). This is all assuming that the Stores are created with |
Over in #1746 @dcherian discovered the following bug:
Setting data with
a[:] = nparray
, followed bya.store_path.store.close()
, followed bya[:]
, results in the store getting wiped. This is not intended behavior.this PR adds:
TODO:
Closes #2067