-
-
Notifications
You must be signed in to change notification settings - Fork 283
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
document storage classes and some developer apis #2279
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
fe49f5f
fix: zarr v2 compatability fixes
jhamman 9a1580b
move zarr.store to zarr.storage
jhamman 0d89912
make chunks a tuple
jhamman d78e384
Merge branch 'v3' of https://github.com/zarr-developers/zarr-python i…
jhamman e534279
Apply suggestions from code review
jhamman dea4a3d
Merge branch 'v3' of https://github.com/zarr-developers/zarr-python i…
jhamman 7800f38
Merge branch 'v3' of https://github.com/zarr-developers/zarr-python i…
jhamman 93b61fc
more merge conflict resolution
jhamman 88afe52
Merge branch 'v3' of https://github.com/zarr-developers/zarr-python i…
jhamman fb6752d
fixups
jhamman 0b1dedc
fixup zipstore
jhamman 322918a
Apply suggestions from code review
jhamman a95d54a
Apply suggestions from code review
jhamman 128eb53
add test
jhamman 3c170ef
Merge branch 'v3' of https://github.com/zarr-developers/zarr-python i…
jhamman 54ab9ef
extend test
jhamman 77f2938
clean up parents
jhamman 2295d76
debug race condition
jhamman 5879d67
more debug
jhamman f54f6f2
document storage classes and some developer apis
jhamman 3940d22
Update src/zarr/core/array.py
jhamman c9d1c50
Merge branch 'fix/dask-compat' into doc/storage
jhamman 83fa3ac
Merge branch 'v3' of https://github.com/zarr-developers/zarr-python i…
jhamman f2137fb
Merge branch 'doc/storage' of github.com:jhamman/zarr-python into doc…
jhamman f44601b
Merge branch 'v3' into doc/storage
jhamman 731c22a
Merge branch 'v3' of https://github.com/zarr-developers/zarr-python i…
jhamman 4e93aa0
inherit docstrings from baseclass
jhamman dad94e2
Merge branch 'doc/storage' of github.com:jhamman/zarr-python into doc…
jhamman 5477d32
fix sphinx warning
jhamman 728d4f7
# docstring inherited
jhamman e293b47
Merge branch 'v3' of https://github.com/zarr-developers/zarr-python i…
jhamman cee730c
Merge branch 'v3' of https://github.com/zarr-developers/zarr-python i…
jhamman 3f7290f
add storage guide
jhamman 35a6428
add missing file
jhamman a78461e
update links
jhamman eff01ce
Merge branch 'v3' into doc/storage
jhamman c1f0923
Merge branch 'v3' into doc/storage
dstansby File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ Guide | |
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
storage | ||
consolidated_metadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
Storage | ||
======= | ||
|
||
Zarr-Python supports multiple storage backends, including: local file systems, | ||
Zip files, remote stores via ``fspec`` (S3, HTTP, etc.), and in-memory stores. In | ||
Zarr-Python 3, stores must implement the abstract store API from | ||
:class:`zarr.abc.store.Store`. | ||
|
||
.. note:: | ||
Unlike Zarr-Python 2 where the store interface was built around a generic ``MutableMapping`` | ||
API, Zarr-Python 3 utilizes a custom store API that utilizes Python's AsyncIO library. | ||
|
||
Implicit Store Creation | ||
----------------------- | ||
|
||
In most cases, it is not required to create a ``Store`` object explicitly. Passing a string | ||
to Zarr's top level API will result in the store being created automatically. | ||
|
||
.. code-block:: python | ||
|
||
>>> import zarr | ||
>>> zarr.open("data/foo/bar", mode="r") # implicitly creates a LocalStore | ||
<Group file://data/foo/bar> | ||
>>> zarr.open("s3://foo/bar", mode="r") # implicitly creates a RemoteStore | ||
<Group s3://foo/bar> | ||
>>> data = {} | ||
>>> zarr.open(data, mode="w") # implicitly creates a MemoryStore | ||
<Group memory://4791444288> | ||
|
||
Explicit Store Creation | ||
----------------------- | ||
|
||
In some cases, it may be helpful to create a store instance directly. Zarr-Python offers four | ||
built-in store: :class:`zarr.storage.LocalStore`, :class:`zarr.storage.RemoteStore`, | ||
:class:`zarr.storage.ZipStore`, and :class:`zarr.storage.MemoryStore`. | ||
|
||
Local Store | ||
~~~~~~~~~~~ | ||
|
||
The :class:`zarr.storage.LocalStore` stores data in a nested set of directories on a local | ||
filesystem. | ||
|
||
.. code-block:: python | ||
|
||
>>> import zarr | ||
>>> store = zarr.storage.LocalStore("data/foo/bar", mode="r") | ||
>>> zarr.open(store=store) | ||
<Group file://data/foo/bar> | ||
|
||
Zip Store | ||
~~~~~~~~~ | ||
|
||
The :class:`zarr.storage.ZipStore` stores the contents of a Zarr hierarchy in a single | ||
Zip file. The `Zip Store specification_` is currently in draft form. | ||
|
||
.. code-block:: python | ||
|
||
>>> import zarr | ||
>>> store = zarr.storage.ZipStore("data.zip", mode="w") | ||
>>> zarr.open(store=store, shape=(2,)) | ||
<Array zip://data.zip shape=(2,) dtype=float64 | ||
|
||
Remote Store | ||
~~~~~~~~~~~~ | ||
|
||
The :class:`zarr.storage.RemoteStore` stores the contents of a Zarr hierarchy in following the same | ||
logical layout as the ``LocalStore``, except the store is assumed to be on a remote storage system | ||
such as cloud object storage (e.g. AWS S3, Google Cloud Storage, Azure Blob Store). The | ||
:class:`zarr.storage.RemoteStore` is backed by `Fsspec_` and can support any Fsspec backend | ||
that implements the `AbstractFileSystem` API, | ||
|
||
.. code-block:: python | ||
|
||
>>> import zarr | ||
>>> store = zarr.storage.RemoteStore("gs://foo/bar", mode="r") | ||
>>> zarr.open(store=store) | ||
<Array <RemoteStore(GCSFileSystem, foo/bar)> shape=(10, 20) dtype=float32> | ||
|
||
Memory Store | ||
~~~~~~~~~~~~ | ||
|
||
The :class:`zarr.storage.RemoteStore` a in-memory store that allows for serialization of | ||
Zarr data (metadata and chunks) to a dictionary. | ||
|
||
.. code-block:: python | ||
|
||
>>> import zarr | ||
>>> data = {} | ||
>>> store = zarr.storage.MemoryStore(data, mode="w") | ||
>>> zarr.open(store=store, shape=(2, )) | ||
<Array memory://4943638848 shape=(2,) dtype=float64> | ||
|
||
Developing custom stores | ||
------------------------ | ||
|
||
Zarr-Python :class:`zarr.abc.store.Store` API is meant to be extended. The Store Abstract Base | ||
Class includes all of the methods needed to be a fully operational store in Zarr Python. | ||
Zarr also provides a test harness for custom stores: :class:`zarr.testing.store.StoreTests`. | ||
|
||
.. _Zip Store Specification: https://github.com/zarr-developers/zarr-specs/pull/311 | ||
.. _Fsspec: https://zarr-specs.readthedocs.io/en/latest/v3/core/v3.0.html#consolidated-metadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could we define these as a string somewhere, and then re-use it here and lower down by making the docstring a format string? I worry about lists like this getting out of sync if they're duplicated across docstrings.
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 decided not to do that here because its just this one method. If we have a docstring template tool in the future, I think it would be great to bring that to bear here (and even more so on the Group/Array classes).