-
-
Notifications
You must be signed in to change notification settings - Fork 274
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
Add array storage helpers #2065
base: v3
Are you sure you want to change the base?
Conversation
@tomwhite let me know if this looks workable for you |
Thanks @d-v-b this looks great! I wondered why you deprecated |
my thinking for this is twofold:
does this check out? I'm sorry if the warnings are inconvenient, but I really would like to find a proper expression of v3 semantics on the |
to expand on this: v3 introduces two kinds of chunks, read-chunks and write chunks. the number of read chunks may not equal the number of write chunks. so where we had 1 |
""" | ||
for key, value in dict.items(): | ||
await self.set(key, value) | ||
return None |
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.
IIUC, this is just a helper for our test suite, right? I think I'd favor moving this to either a utility function or a public API (something like Store.set_many()
). Or perhaps our set_partial_values
signature needs to evolve to handle this type of thing.
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.
right now it's just being used in the test suite, so i'd be happy splitting it off into a private stand-alone function that takes a store. the dict part is just for convenience; what we ultimately will need for proper batching is just a store method that takes tuple[tuple[key, value], ...]
, which I don't think we have yet?
…nto add-array-storage-helpers
…ods, and they can take an origin kwarg
…nto add-array-storage-helpers
This PR adds
nchunks
,nbytes
, andnchunks_initialized
functionality from 2.x.closes #2027
depends on #2064
details
Adds the following to
array.py
:(AsyncArray / Array).nchunks
: deprecated, the total number of chunks in the array. exists for 2.xx compatibility.(AsyncArray / Array).cdata_shape
: deprecated, the shape of the chunk grid. exists for 2.xx compatibility.(AsyncArray / Array).nbytes
: the total number of bytes that the array can store(AsyncArray / Array)._iter_chunk_coords
: an iterator over tuples of ints which represent positions in the chunk grid(AsyncArray / Array)._iter_chunk_regions
: an iterator over slices which represent the contiguous array region spanned by each chunk(AsyncArray / Array)._iter_chunk_keys
: an iterator over strings which represent the paths in storage for all the chunkschunks_initialized(array)
: a function that takes an array and returns a tuple of the chunk keys for that array that exist in storage. this also has tests.nchunks_initialized(array)
: deprecated, a function that callslen(chunks_initialized(array))
. this exists for 2.xx compatibility.All of the above
_iter_chunk_*
methods should be considered private and provisional. I added them because their functionality is valuable, but eventually I think we will have a better array API that renders these methods obsolete. If we think these are cluttering the array API, I'd be happy splitting them off into stand-alone functions.iter_grid
toindexing.py
, this just provides lexicographic iteration over the elements of a bounded N-dimensional, positive grid (e.g., a grid of chunks).TODO: