Skip to content
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

Checking that the store is an instance of dict seem incorrect. #636

Closed

Conversation

Carreau
Copy link
Contributor

@Carreau Carreau commented Oct 22, 2020

Indeed MemoryStore is an instance of mutable mapping that have the same
property as dict, but would not be seen as as instance of dict.

With some caveat inlines.

zarr/core.py Show resolved Hide resolved
zarr/storage.py Outdated Show resolved Hide resolved
@Carreau Carreau force-pushed the memorystore-is-not-dict branch from b339f56 to c7e6ce3 Compare October 22, 2020 18:31
@codecov
Copy link

codecov bot commented Oct 22, 2020

Codecov Report

Merging #636 (8c22ad3) into master (0c530c3) will increase coverage by 0.48%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #636      +/-   ##
==========================================
+ Coverage   99.45%   99.94%   +0.48%     
==========================================
  Files          28       28              
  Lines       10287    10288       +1     
==========================================
+ Hits        10231    10282      +51     
+ Misses         56        6      -50     
Impacted Files Coverage Δ
zarr/storage.py 100.00% <ø> (ø)
zarr/core.py 100.00% <100.00%> (ø)
zarr/util.py 100.00% <0.00%> (+15.06%) ⬆️

Indeed MemoryStore is an instance of mutable mapping that have the same
property as dict, but woudl not be seen as as instance of dict.
@Carreau Carreau force-pushed the memorystore-is-not-dict branch from 676754a to 4a39c97 Compare October 22, 2020 20:46
@Carreau Carreau mentioned this pull request Oct 22, 2020
docs/tutorial.rst Outdated Show resolved Hide resolved
@@ -1955,7 +1956,7 @@ def _encode_chunk(self, chunk):
cdata = chunk

# ensure in-memory data is immutable and easy to compare
if isinstance(self.chunk_store, dict):
if isinstance(self.chunk_store, MutableMapping):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned upthread, this change is too broad and may force unnecessary copies. The goal of this check was to make sure there would not be unexpected mutation of in-memory data so would copy to bytes before storing. If we are writing to disk or sending to a cloud store, this is unneeded. Perhaps the check needs to be updated, but maybe that can be handled as part of Greg's work?

@jakirkham jakirkham mentioned this pull request Dec 10, 2021
6 tasks
@jakirkham
Copy link
Member

Have cherry-picked the doc fixes from here into PR ( #907 )

@joshmoore
Copy link
Member

@grlee77 : any thoughts on what to do here?

@jakirkham
Copy link
Member

Guessing Greg has likely handled this along with other things in his PRs. Though could be wrong about that.

@joshmoore
Copy link
Member

I think the same is true. Closing in favor of #898 and friends.

@joshmoore joshmoore closed this May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants