zarr.storage ============ .. py:module:: zarr.storage Attributes ---------- .. autoapisummary:: zarr.storage.StoreLike Classes ------- .. autoapisummary:: zarr.storage.FsspecStore zarr.storage.GpuMemoryStore zarr.storage.LocalStore zarr.storage.LoggingStore zarr.storage.MemoryStore zarr.storage.ObjectStore zarr.storage.StorePath zarr.storage.WrapperStore zarr.storage.ZipStore Package Contents ---------------- .. py:class:: FsspecStore(fs: fsspec.asyn.AsyncFileSystem, read_only: bool = False, path: str = '/', allowed_exceptions: tuple[type[Exception], Ellipsis] = ALLOWED_EXCEPTIONS) Bases: :py:obj:`zarr.abc.store.Store` Store for remote data based on FSSpec. :Parameters: **fs** : AsyncFileSystem The Async FSSpec filesystem to use with this store. **read_only** : bool Whether the store is read-only **path** : str The root path of the store. This should be a relative path and must not include the filesystem scheme. **allowed_exceptions** : tuple[type[Exception], ...] When fetching data, these cases will be deemed to correspond to missing keys. :Attributes: **fs** .. **allowed_exceptions** .. **supports_writes** .. **supports_deletes** .. **supports_partial_writes** .. **supports_listing** .. :Raises: TypeError If the Filesystem does not support async operations. ValueError If the path argument includes a scheme. :Warns: UserWarning If the file system (fs) was not created with `asynchronous=True`. .. seealso:: :obj:`FsspecStore.from_upath` .. :obj:`FsspecStore.from_url` .. .. !! processed by numpydoc !! .. py:method:: clear() -> None :async: Clear the store. Remove all keys and values from the store. .. !! processed by numpydoc !! .. py:method:: close() -> None Close the store. .. !! processed by numpydoc !! .. py:method:: delete(key: str) -> None :async: Remove a key from the store :Parameters: **key** : str .. .. !! processed by numpydoc !! .. py:method:: delete_dir(prefix: str) -> None :async: Remove all keys and prefixes in the store that begin with a given prefix. .. !! processed by numpydoc !! .. py:method:: exists(key: str) -> bool :async: Check if a key exists in the store. :Parameters: **key** : str .. :Returns: bool .. .. !! processed by numpydoc !! .. py:method:: from_mapper(fs_map: fsspec.mapping.FSMap, read_only: bool = False, allowed_exceptions: tuple[type[Exception], Ellipsis] = ALLOWED_EXCEPTIONS) -> FsspecStore :classmethod: Create a FsspecStore from a FSMap object. :Parameters: **fs_map** : FSMap Fsspec mutable mapping object. **read_only** : bool Whether the store is read-only, defaults to False. **allowed_exceptions** : tuple, optional The exceptions that are allowed to be raised when accessing the store. Defaults to ALLOWED_EXCEPTIONS. :Returns: FsspecStore .. .. !! processed by numpydoc !! .. py:method:: from_upath(upath: Any, read_only: bool = False, allowed_exceptions: tuple[type[Exception], Ellipsis] = ALLOWED_EXCEPTIONS) -> FsspecStore :classmethod: Create a FsspecStore from an upath object. :Parameters: **upath** : UPath The upath to the root of the store. **read_only** : bool Whether the store is read-only, defaults to False. **allowed_exceptions** : tuple, optional The exceptions that are allowed to be raised when accessing the store. Defaults to ALLOWED_EXCEPTIONS. :Returns: FsspecStore .. .. !! processed by numpydoc !! .. py:method:: from_url(url: str, storage_options: dict[str, Any] | None = None, read_only: bool = False, allowed_exceptions: tuple[type[Exception], Ellipsis] = ALLOWED_EXCEPTIONS) -> FsspecStore :classmethod: Create a FsspecStore from a URL. The type of store is determined from the URL scheme. :Parameters: **url** : str The URL to the root of the store. **storage_options** : dict, optional The options to pass to fsspec when creating the filesystem. **read_only** : bool Whether the store is read-only, defaults to False. **allowed_exceptions** : tuple, optional The exceptions that are allowed to be raised when accessing the store. Defaults to ALLOWED_EXCEPTIONS. :Returns: FsspecStore .. .. !! processed by numpydoc !! .. py:method:: get(key: str, prototype: zarr.core.buffer.BufferPrototype, byte_range: zarr.abc.store.ByteRequest | None = None) -> zarr.core.buffer.Buffer | None :async: Retrieve the value associated with a given key. :Parameters: **key** : str .. **prototype** : BufferPrototype The prototype of the output buffer. Stores may support a default buffer prototype. **byte_range** : ByteRequest, optional ByteRequest may be one of the following. If not provided, all data associated with the key is retrieved. - RangeByteRequest(int, int): Request a specific range of bytes in the form (start, end). The end is exclusive. If the given range is zero-length or starts after the end of the object, an error will be returned. Additionally, if the range ends after the end of the object, the entire remainder of the object will be returned. Otherwise, the exact requested range will be returned. - OffsetByteRequest(int): Request all bytes starting from a given byte offset. This is equivalent to bytes={int}- as an HTTP header. - SuffixByteRequest(int): Request the last int bytes. Note that here, int is the size of the request, not the byte offset. This is equivalent to bytes=-{int} as an HTTP header. :Returns: Buffer .. .. !! processed by numpydoc !! .. py:method:: get_partial_values(prototype: zarr.core.buffer.BufferPrototype, key_ranges: collections.abc.Iterable[tuple[str, zarr.abc.store.ByteRequest | None]]) -> list[zarr.core.buffer.Buffer | None] :async: Retrieve possibly partial values from given key_ranges. :Parameters: **prototype** : BufferPrototype The prototype of the output buffer. Stores may support a default buffer prototype. **key_ranges** : Iterable[tuple[str, tuple[int | None, int | None]]] Ordered set of key, range pairs, a key may occur multiple times with different ranges :Returns: list of values, in the order of the key_ranges, may contain null/none for missing keys .. .. !! processed by numpydoc !! .. py:method:: getsize(key: str) -> int :async: Return the size, in bytes, of a value in a Store. :Parameters: **key** : str .. :Returns: **nbytes** : int The size of the value (in bytes). :Raises: FileNotFoundError When the given key does not exist in the store. .. !! processed by numpydoc !! .. py:method:: getsize_prefix(prefix: str) -> int :async: Return the size, in bytes, of all values under a prefix. :Parameters: **prefix** : str The prefix of the directory to measure. :Returns: **nbytes** : int The sum of the sizes of the values in the directory (in bytes). .. seealso:: :obj:`zarr.Array.nbytes_stored` .. :obj:`Store.getsize` .. .. rubric:: Notes ``getsize_prefix`` is just provided as a potentially faster alternative to listing all the keys under a prefix calling :meth:`Store.getsize` on each. In general, ``prefix`` should be the path of an Array or Group in the Store. Implementations may differ on the behavior when some other ``prefix`` is provided. .. !! processed by numpydoc !! .. py:method:: is_empty(prefix: str) -> bool :async: Check if the directory is empty. :Parameters: **prefix** : str Prefix of keys to check. :Returns: bool True if the store is empty, False otherwise. .. !! processed by numpydoc !! .. py:method:: list() -> collections.abc.AsyncIterator[str] :async: Retrieve all keys in the store. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: list_dir(prefix: str) -> collections.abc.AsyncIterator[str] :async: Retrieve all keys and prefixes with a given prefix and which do not contain the character “/” after the given prefix. :Parameters: **prefix** : str .. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: list_prefix(prefix: str) -> collections.abc.AsyncIterator[str] :async: Retrieve all keys in the store that begin with a given prefix. Keys are returned relative to the root of the store. :Parameters: **prefix** : str .. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: open(*args: Any, **kwargs: Any) -> Self :classmethod: :async: Create and open the store. :Parameters: **\*args** : Any Positional arguments to pass to the store constructor. **\*\*kwargs** : Any Keyword arguments to pass to the store constructor. :Returns: Store The opened store instance. .. !! processed by numpydoc !! .. py:method:: set(key: str, value: zarr.core.buffer.Buffer, byte_range: tuple[int, int] | None = None) -> None :async: Store a (key, value) pair. :Parameters: **key** : str .. **value** : Buffer .. .. !! processed by numpydoc !! .. py:method:: set_if_not_exists(key: str, value: zarr.core.buffer.Buffer) -> None :async: Store a key to ``value`` if the key is not already present. :Parameters: **key** : str .. **value** : Buffer .. .. !! processed by numpydoc !! .. py:method:: set_partial_values(key_start_values: collections.abc.Iterable[tuple[str, int, zarr.core.common.BytesLike]]) -> None :abstractmethod: :async: Store values at a given key, starting at byte range_start. :Parameters: **key_start_values** : list[tuple[str, int, BytesLike]] set of key, range_start, values triples, a key may occur multiple times with different range_starts, range_starts (considering the length of the respective values) must not specify overlapping ranges for the same key .. !! processed by numpydoc !! .. py:method:: with_read_only(read_only: bool = False) -> FsspecStore Return a new store with a new read_only setting. The new store points to the same location with the specified new read_only state. The returned Store is not automatically opened, and this store is not automatically closed. :Parameters: **read_only** If True, the store will be created in read-only mode. Defaults to False. :Returns: A new store of the same type with the new read only attribute. .. .. !! processed by numpydoc !! .. py:attribute:: allowed_exceptions :type: tuple[type[Exception], Ellipsis] .. py:attribute:: fs :type: fsspec.asyn.AsyncFileSystem .. py:attribute:: path :type: str .. py:property:: read_only :type: bool Is the store read-only? .. !! processed by numpydoc !! .. py:property:: supports_consolidated_metadata :type: bool Does the store support consolidated metadata?. If it doesn't an error will be raised on requests to consolidate the metadata. Returning `False` can be useful for stores which implement their own consolidation mechanism outside of the zarr-python implementation. .. !! processed by numpydoc !! .. py:attribute:: supports_deletes :type: bool :value: True Does the store support deletes? .. !! processed by numpydoc !! .. py:attribute:: supports_listing :type: bool :value: True Does the store support listing? .. !! processed by numpydoc !! .. py:attribute:: supports_partial_writes :type: bool :value: False Does the store support partial writes? .. !! processed by numpydoc !! .. py:attribute:: supports_writes :type: bool :value: True Does the store support writes? .. !! processed by numpydoc !! .. py:class:: GpuMemoryStore(store_dict: collections.abc.MutableMapping[str, zarr.core.buffer.gpu.Buffer] | None = None, *, read_only: bool = False) Bases: :py:obj:`MemoryStore` Store for GPU memory. Stores every chunk in GPU memory irrespective of the original location. The dictionary of buffers to initialize this memory store with *must* be GPU Buffers. Writing data to this store through ``.set`` will move the buffer to the GPU if necessary. :Parameters: **store_dict** : MutableMapping, optional A mutable mapping with string keys and :class:`zarr.core.buffer.gpu.Buffer` values. **read_only** : bool Whether to open the store in read-only mode. .. !! processed by numpydoc !! .. py:method:: clear() -> None :async: Clear the store. Remove all keys and values from the store. .. !! processed by numpydoc !! .. py:method:: close() -> None Close the store. .. !! processed by numpydoc !! .. py:method:: delete(key: str) -> None :async: Remove a key from the store :Parameters: **key** : str .. .. !! processed by numpydoc !! .. py:method:: delete_dir(prefix: str) -> None :async: Remove all keys and prefixes in the store that begin with a given prefix. .. !! processed by numpydoc !! .. py:method:: exists(key: str) -> bool :async: Check if a key exists in the store. :Parameters: **key** : str .. :Returns: bool .. .. !! processed by numpydoc !! .. py:method:: from_dict(store_dict: collections.abc.MutableMapping[str, zarr.core.buffer.Buffer]) -> Self :classmethod: Create a GpuMemoryStore from a dictionary of buffers at any location. The dictionary backing the newly created ``GpuMemoryStore`` will not be the same as ``store_dict``. :Parameters: **store_dict** : mapping A mapping of strings keys to arbitrary Buffers. The buffer data will be moved into a :class:`gpu.Buffer`. :Returns: GpuMemoryStore .. .. !! processed by numpydoc !! .. py:method:: get(key: str, prototype: zarr.core.buffer.BufferPrototype, byte_range: zarr.abc.store.ByteRequest | None = None) -> zarr.core.buffer.Buffer | None :async: Retrieve the value associated with a given key. :Parameters: **key** : str .. **prototype** : BufferPrototype The prototype of the output buffer. Stores may support a default buffer prototype. **byte_range** : ByteRequest, optional ByteRequest may be one of the following. If not provided, all data associated with the key is retrieved. - RangeByteRequest(int, int): Request a specific range of bytes in the form (start, end). The end is exclusive. If the given range is zero-length or starts after the end of the object, an error will be returned. Additionally, if the range ends after the end of the object, the entire remainder of the object will be returned. Otherwise, the exact requested range will be returned. - OffsetByteRequest(int): Request all bytes starting from a given byte offset. This is equivalent to bytes={int}- as an HTTP header. - SuffixByteRequest(int): Request the last int bytes. Note that here, int is the size of the request, not the byte offset. This is equivalent to bytes=-{int} as an HTTP header. :Returns: Buffer .. .. !! processed by numpydoc !! .. py:method:: get_partial_values(prototype: zarr.core.buffer.BufferPrototype, key_ranges: collections.abc.Iterable[tuple[str, zarr.abc.store.ByteRequest | None]]) -> list[zarr.core.buffer.Buffer | None] :async: Retrieve possibly partial values from given key_ranges. :Parameters: **prototype** : BufferPrototype The prototype of the output buffer. Stores may support a default buffer prototype. **key_ranges** : Iterable[tuple[str, tuple[int | None, int | None]]] Ordered set of key, range pairs, a key may occur multiple times with different ranges :Returns: list of values, in the order of the key_ranges, may contain null/none for missing keys .. .. !! processed by numpydoc !! .. py:method:: getsize(key: str) -> int :async: Return the size, in bytes, of a value in a Store. :Parameters: **key** : str .. :Returns: **nbytes** : int The size of the value (in bytes). :Raises: FileNotFoundError When the given key does not exist in the store. .. !! processed by numpydoc !! .. py:method:: getsize_prefix(prefix: str) -> int :async: Return the size, in bytes, of all values under a prefix. :Parameters: **prefix** : str The prefix of the directory to measure. :Returns: **nbytes** : int The sum of the sizes of the values in the directory (in bytes). .. seealso:: :obj:`zarr.Array.nbytes_stored` .. :obj:`Store.getsize` .. .. rubric:: Notes ``getsize_prefix`` is just provided as a potentially faster alternative to listing all the keys under a prefix calling :meth:`Store.getsize` on each. In general, ``prefix`` should be the path of an Array or Group in the Store. Implementations may differ on the behavior when some other ``prefix`` is provided. .. !! processed by numpydoc !! .. py:method:: is_empty(prefix: str) -> bool :async: Check if the directory is empty. :Parameters: **prefix** : str Prefix of keys to check. :Returns: bool True if the store is empty, False otherwise. .. !! processed by numpydoc !! .. py:method:: list() -> collections.abc.AsyncIterator[str] :async: Retrieve all keys in the store. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: list_dir(prefix: str) -> collections.abc.AsyncIterator[str] :async: Retrieve all keys and prefixes with a given prefix and which do not contain the character “/” after the given prefix. :Parameters: **prefix** : str .. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: list_prefix(prefix: str) -> collections.abc.AsyncIterator[str] :async: Retrieve all keys in the store that begin with a given prefix. Keys are returned relative to the root of the store. :Parameters: **prefix** : str .. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: open(*args: Any, **kwargs: Any) -> Self :classmethod: :async: Create and open the store. :Parameters: **\*args** : Any Positional arguments to pass to the store constructor. **\*\*kwargs** : Any Keyword arguments to pass to the store constructor. :Returns: Store The opened store instance. .. !! processed by numpydoc !! .. py:method:: set(key: str, value: zarr.core.buffer.Buffer, byte_range: tuple[int, int] | None = None) -> None :async: Store a (key, value) pair. :Parameters: **key** : str .. **value** : Buffer .. .. !! processed by numpydoc !! .. py:method:: set_if_not_exists(key: str, value: zarr.core.buffer.Buffer) -> None :async: Store a key to ``value`` if the key is not already present. :Parameters: **key** : str .. **value** : Buffer .. .. !! processed by numpydoc !! .. py:method:: set_partial_values(key_start_values: collections.abc.Iterable[tuple[str, int, bytes | bytearray | memoryview[int]]]) -> None :abstractmethod: :async: Store values at a given key, starting at byte range_start. :Parameters: **key_start_values** : list[tuple[str, int, BytesLike]] set of key, range_start, values triples, a key may occur multiple times with different range_starts, range_starts (considering the length of the respective values) must not specify overlapping ranges for the same key .. !! processed by numpydoc !! .. py:method:: with_read_only(read_only: bool = False) -> MemoryStore Return a new store with a new read_only setting. The new store points to the same location with the specified new read_only state. The returned Store is not automatically opened, and this store is not automatically closed. :Parameters: **read_only** If True, the store will be created in read-only mode. Defaults to False. :Returns: A new store of the same type with the new read only attribute. .. .. !! processed by numpydoc !! .. py:property:: read_only :type: bool Is the store read-only? .. !! processed by numpydoc !! .. py:property:: supports_consolidated_metadata :type: bool Does the store support consolidated metadata?. If it doesn't an error will be raised on requests to consolidate the metadata. Returning `False` can be useful for stores which implement their own consolidation mechanism outside of the zarr-python implementation. .. !! processed by numpydoc !! .. py:attribute:: supports_deletes :type: bool :value: True Does the store support deletes? .. !! processed by numpydoc !! .. py:attribute:: supports_listing :type: bool :value: True Does the store support listing? .. !! processed by numpydoc !! .. py:attribute:: supports_partial_writes :type: bool :value: True Does the store support partial writes? .. !! processed by numpydoc !! .. py:attribute:: supports_writes :type: bool :value: True Does the store support writes? .. !! processed by numpydoc !! .. py:class:: LocalStore(root: pathlib.Path | str, *, read_only: bool = False) Bases: :py:obj:`zarr.abc.store.Store` Store for the local file system. :Parameters: **root** : str or Path Directory to use as root of store. **read_only** : bool Whether the store is read-only :Attributes: **supports_writes** .. **supports_deletes** .. **supports_partial_writes** .. **supports_listing** .. **root** .. .. !! processed by numpydoc !! .. py:method:: clear() -> None :async: Clear the store. Remove all keys and values from the store. .. !! processed by numpydoc !! .. py:method:: close() -> None Close the store. .. !! processed by numpydoc !! .. py:method:: delete(key: str) -> None :async: Remove a key from the store. :Parameters: **key** : str .. .. rubric:: Notes If ``key`` is a directory within this store, the entire directory at ``store.root / key`` is deleted. .. !! processed by numpydoc !! .. py:method:: delete_dir(prefix: str) -> None :async: Remove all keys and prefixes in the store that begin with a given prefix. .. !! processed by numpydoc !! .. py:method:: exists(key: str) -> bool :async: Check if a key exists in the store. :Parameters: **key** : str .. :Returns: bool .. .. !! processed by numpydoc !! .. py:method:: get(key: str, prototype: zarr.core.buffer.BufferPrototype | None = None, byte_range: zarr.abc.store.ByteRequest | None = None) -> zarr.core.buffer.Buffer | None :async: Retrieve the value associated with a given key. :Parameters: **key** : str .. **prototype** : BufferPrototype The prototype of the output buffer. Stores may support a default buffer prototype. **byte_range** : ByteRequest, optional ByteRequest may be one of the following. If not provided, all data associated with the key is retrieved. - RangeByteRequest(int, int): Request a specific range of bytes in the form (start, end). The end is exclusive. If the given range is zero-length or starts after the end of the object, an error will be returned. Additionally, if the range ends after the end of the object, the entire remainder of the object will be returned. Otherwise, the exact requested range will be returned. - OffsetByteRequest(int): Request all bytes starting from a given byte offset. This is equivalent to bytes={int}- as an HTTP header. - SuffixByteRequest(int): Request the last int bytes. Note that here, int is the size of the request, not the byte offset. This is equivalent to bytes=-{int} as an HTTP header. :Returns: Buffer .. .. !! processed by numpydoc !! .. py:method:: get_partial_values(prototype: zarr.core.buffer.BufferPrototype, key_ranges: collections.abc.Iterable[tuple[str, zarr.abc.store.ByteRequest | None]]) -> list[zarr.core.buffer.Buffer | None] :async: Retrieve possibly partial values from given key_ranges. :Parameters: **prototype** : BufferPrototype The prototype of the output buffer. Stores may support a default buffer prototype. **key_ranges** : Iterable[tuple[str, tuple[int | None, int | None]]] Ordered set of key, range pairs, a key may occur multiple times with different ranges :Returns: list of values, in the order of the key_ranges, may contain null/none for missing keys .. .. !! processed by numpydoc !! .. py:method:: getsize(key: str) -> int :async: Return the size, in bytes, of a value in a Store. :Parameters: **key** : str .. :Returns: **nbytes** : int The size of the value (in bytes). :Raises: FileNotFoundError When the given key does not exist in the store. .. !! processed by numpydoc !! .. py:method:: getsize_prefix(prefix: str) -> int :async: Return the size, in bytes, of all values under a prefix. :Parameters: **prefix** : str The prefix of the directory to measure. :Returns: **nbytes** : int The sum of the sizes of the values in the directory (in bytes). .. seealso:: :obj:`zarr.Array.nbytes_stored` .. :obj:`Store.getsize` .. .. rubric:: Notes ``getsize_prefix`` is just provided as a potentially faster alternative to listing all the keys under a prefix calling :meth:`Store.getsize` on each. In general, ``prefix`` should be the path of an Array or Group in the Store. Implementations may differ on the behavior when some other ``prefix`` is provided. .. !! processed by numpydoc !! .. py:method:: is_empty(prefix: str) -> bool :async: Check if the directory is empty. :Parameters: **prefix** : str Prefix of keys to check. :Returns: bool True if the store is empty, False otherwise. .. !! processed by numpydoc !! .. py:method:: list() -> collections.abc.AsyncIterator[str] :async: Retrieve all keys in the store. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: list_dir(prefix: str) -> collections.abc.AsyncIterator[str] :async: Retrieve all keys and prefixes with a given prefix and which do not contain the character “/” after the given prefix. :Parameters: **prefix** : str .. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: list_prefix(prefix: str) -> collections.abc.AsyncIterator[str] :async: Retrieve all keys in the store that begin with a given prefix. Keys are returned relative to the root of the store. :Parameters: **prefix** : str .. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: move(dest_root: pathlib.Path | str) -> None :async: Move the store to another path. The old root directory is deleted. .. !! processed by numpydoc !! .. py:method:: open(*args: Any, **kwargs: Any) -> Self :classmethod: :async: Create and open the store. :Parameters: **\*args** : Any Positional arguments to pass to the store constructor. **\*\*kwargs** : Any Keyword arguments to pass to the store constructor. :Returns: Store The opened store instance. .. !! processed by numpydoc !! .. py:method:: set(key: str, value: zarr.core.buffer.Buffer) -> None :async: Store a (key, value) pair. :Parameters: **key** : str .. **value** : Buffer .. .. !! processed by numpydoc !! .. py:method:: set_if_not_exists(key: str, value: zarr.core.buffer.Buffer) -> None :async: Store a key to ``value`` if the key is not already present. :Parameters: **key** : str .. **value** : Buffer .. .. !! processed by numpydoc !! .. py:method:: set_partial_values(key_start_values: collections.abc.Iterable[tuple[str, int, bytes | bytearray | memoryview]]) -> None :async: Store values at a given key, starting at byte range_start. :Parameters: **key_start_values** : list[tuple[str, int, BytesLike]] set of key, range_start, values triples, a key may occur multiple times with different range_starts, range_starts (considering the length of the respective values) must not specify overlapping ranges for the same key .. !! processed by numpydoc !! .. py:method:: with_read_only(read_only: bool = False) -> LocalStore Return a new store with a new read_only setting. The new store points to the same location with the specified new read_only state. The returned Store is not automatically opened, and this store is not automatically closed. :Parameters: **read_only** If True, the store will be created in read-only mode. Defaults to False. :Returns: A new store of the same type with the new read only attribute. .. .. !! processed by numpydoc !! .. py:property:: read_only :type: bool Is the store read-only? .. !! processed by numpydoc !! .. py:attribute:: root :type: pathlib.Path .. py:property:: supports_consolidated_metadata :type: bool Does the store support consolidated metadata?. If it doesn't an error will be raised on requests to consolidate the metadata. Returning `False` can be useful for stores which implement their own consolidation mechanism outside of the zarr-python implementation. .. !! processed by numpydoc !! .. py:attribute:: supports_deletes :type: bool :value: True Does the store support deletes? .. !! processed by numpydoc !! .. py:attribute:: supports_listing :type: bool :value: True Does the store support listing? .. !! processed by numpydoc !! .. py:attribute:: supports_partial_writes :type: bool :value: True Does the store support partial writes? .. !! processed by numpydoc !! .. py:attribute:: supports_writes :type: bool :value: True Does the store support writes? .. !! processed by numpydoc !! .. py:class:: LoggingStore(store: T_Store, log_level: str = 'DEBUG', log_handler: logging.Handler | None = None) Bases: :py:obj:`zarr.storage._wrapper.WrapperStore`\ [\ :py:obj:`T_Store`\ ] Store that logs all calls to another wrapped store. :Parameters: **store** : Store Store to wrap **log_level** : str Log level **log_handler** : logging.Handler Log handler :Attributes: **counter** : dict Counter of number of times each method has been called .. !! processed by numpydoc !! .. py:method:: clear() -> None :async: Clear the store. Remove all keys and values from the store. .. !! processed by numpydoc !! .. py:method:: close() -> None Close the store. .. !! processed by numpydoc !! .. py:method:: delete(key: str) -> None :async: Remove a key from the store :Parameters: **key** : str .. .. !! processed by numpydoc !! .. py:method:: delete_dir(prefix: str) -> None :async: Remove all keys and prefixes in the store that begin with a given prefix. .. !! processed by numpydoc !! .. py:method:: exists(key: str) -> bool :async: Check if a key exists in the store. :Parameters: **key** : str .. :Returns: bool .. .. !! processed by numpydoc !! .. py:method:: get(key: str, prototype: zarr.core.buffer.BufferPrototype, byte_range: zarr.abc.store.ByteRequest | None = None) -> zarr.core.buffer.Buffer | None :async: Retrieve the value associated with a given key. :Parameters: **key** : str .. **prototype** : BufferPrototype The prototype of the output buffer. Stores may support a default buffer prototype. **byte_range** : ByteRequest, optional ByteRequest may be one of the following. If not provided, all data associated with the key is retrieved. - RangeByteRequest(int, int): Request a specific range of bytes in the form (start, end). The end is exclusive. If the given range is zero-length or starts after the end of the object, an error will be returned. Additionally, if the range ends after the end of the object, the entire remainder of the object will be returned. Otherwise, the exact requested range will be returned. - OffsetByteRequest(int): Request all bytes starting from a given byte offset. This is equivalent to bytes={int}- as an HTTP header. - SuffixByteRequest(int): Request the last int bytes. Note that here, int is the size of the request, not the byte offset. This is equivalent to bytes=-{int} as an HTTP header. :Returns: Buffer .. .. !! processed by numpydoc !! .. py:method:: get_partial_values(prototype: zarr.core.buffer.BufferPrototype, key_ranges: collections.abc.Iterable[tuple[str, zarr.abc.store.ByteRequest | None]]) -> list[zarr.core.buffer.Buffer | None] :async: Retrieve possibly partial values from given key_ranges. :Parameters: **prototype** : BufferPrototype The prototype of the output buffer. Stores may support a default buffer prototype. **key_ranges** : Iterable[tuple[str, tuple[int | None, int | None]]] Ordered set of key, range pairs, a key may occur multiple times with different ranges :Returns: list of values, in the order of the key_ranges, may contain null/none for missing keys .. .. !! processed by numpydoc !! .. py:method:: getsize(key: str) -> int :async: Return the size, in bytes, of a value in a Store. :Parameters: **key** : str .. :Returns: **nbytes** : int The size of the value (in bytes). :Raises: FileNotFoundError When the given key does not exist in the store. .. !! processed by numpydoc !! .. py:method:: getsize_prefix(prefix: str) -> int :async: Return the size, in bytes, of all values under a prefix. :Parameters: **prefix** : str The prefix of the directory to measure. :Returns: **nbytes** : int The sum of the sizes of the values in the directory (in bytes). .. seealso:: :obj:`zarr.Array.nbytes_stored` .. :obj:`Store.getsize` .. .. rubric:: Notes ``getsize_prefix`` is just provided as a potentially faster alternative to listing all the keys under a prefix calling :meth:`Store.getsize` on each. In general, ``prefix`` should be the path of an Array or Group in the Store. Implementations may differ on the behavior when some other ``prefix`` is provided. .. !! processed by numpydoc !! .. py:method:: is_empty(prefix: str = '') -> bool :async: Check if the directory is empty. :Parameters: **prefix** : str Prefix of keys to check. :Returns: bool True if the store is empty, False otherwise. .. !! processed by numpydoc !! .. py:method:: list() -> collections.abc.AsyncGenerator[str, None] :async: Retrieve all keys in the store. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: list_dir(prefix: str) -> collections.abc.AsyncGenerator[str, None] :async: Retrieve all keys and prefixes with a given prefix and which do not contain the character “/” after the given prefix. :Parameters: **prefix** : str .. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: list_prefix(prefix: str) -> collections.abc.AsyncGenerator[str, None] :async: Retrieve all keys in the store that begin with a given prefix. Keys are returned relative to the root of the store. :Parameters: **prefix** : str .. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: log(hint: Any = '') -> collections.abc.Generator[None, None, None] Context manager to log method calls Each call to the wrapped store is logged to the configured logger and added to the counter dict. .. !! processed by numpydoc !! .. py:method:: open(store_cls: type[T_Store], *args: Any, **kwargs: Any) -> Self :classmethod: :async: Create and open the store. :Parameters: **\*args** : Any Positional arguments to pass to the store constructor. **\*\*kwargs** : Any Keyword arguments to pass to the store constructor. :Returns: Store The opened store instance. .. !! processed by numpydoc !! .. py:method:: set(key: str, value: zarr.core.buffer.Buffer) -> None :async: Store a (key, value) pair. :Parameters: **key** : str .. **value** : Buffer .. .. !! processed by numpydoc !! .. py:method:: set_if_not_exists(key: str, value: zarr.core.buffer.Buffer) -> None :async: Store a key to ``value`` if the key is not already present. :Parameters: **key** : str .. **value** : Buffer .. .. !! processed by numpydoc !! .. py:method:: set_partial_values(key_start_values: collections.abc.Iterable[tuple[str, int, bytes | bytearray | memoryview]]) -> None :async: Store values at a given key, starting at byte range_start. :Parameters: **key_start_values** : list[tuple[str, int, BytesLike]] set of key, range_start, values triples, a key may occur multiple times with different range_starts, range_starts (considering the length of the respective values) must not specify overlapping ranges for the same key .. !! processed by numpydoc !! .. py:method:: with_read_only(read_only: bool = False) -> Store :abstractmethod: Return a new store with a new read_only setting. The new store points to the same location with the specified new read_only state. The returned Store is not automatically opened, and this store is not automatically closed. :Parameters: **read_only** If True, the store will be created in read-only mode. Defaults to False. :Returns: A new store of the same type with the new read only attribute. .. .. !! processed by numpydoc !! .. py:attribute:: counter :type: collections.defaultdict[str, int] .. py:attribute:: log_handler :value: None .. py:attribute:: log_level :value: 'DEBUG' .. py:property:: read_only :type: bool Is the store read-only? .. !! processed by numpydoc !! .. py:property:: supports_consolidated_metadata :type: bool Does the store support consolidated metadata?. If it doesn't an error will be raised on requests to consolidate the metadata. Returning `False` can be useful for stores which implement their own consolidation mechanism outside of the zarr-python implementation. .. !! processed by numpydoc !! .. py:property:: supports_deletes :type: bool Does the store support deletes? .. !! processed by numpydoc !! .. py:property:: supports_listing :type: bool Does the store support listing? .. !! processed by numpydoc !! .. py:property:: supports_partial_writes :type: bool Does the store support partial writes? .. !! processed by numpydoc !! .. py:property:: supports_writes :type: bool Does the store support writes? .. !! processed by numpydoc !! .. py:class:: MemoryStore(store_dict: collections.abc.MutableMapping[str, zarr.core.buffer.Buffer] | None = None, *, read_only: bool = False) Bases: :py:obj:`zarr.abc.store.Store` Store for local memory. :Parameters: **store_dict** : dict Initial data **read_only** : bool Whether the store is read-only :Attributes: **supports_writes** .. **supports_deletes** .. **supports_partial_writes** .. **supports_listing** .. .. !! processed by numpydoc !! .. py:method:: clear() -> None :async: Clear the store. Remove all keys and values from the store. .. !! processed by numpydoc !! .. py:method:: close() -> None Close the store. .. !! processed by numpydoc !! .. py:method:: delete(key: str) -> None :async: Remove a key from the store :Parameters: **key** : str .. .. !! processed by numpydoc !! .. py:method:: delete_dir(prefix: str) -> None :async: Remove all keys and prefixes in the store that begin with a given prefix. .. !! processed by numpydoc !! .. py:method:: exists(key: str) -> bool :async: Check if a key exists in the store. :Parameters: **key** : str .. :Returns: bool .. .. !! processed by numpydoc !! .. py:method:: get(key: str, prototype: zarr.core.buffer.BufferPrototype, byte_range: zarr.abc.store.ByteRequest | None = None) -> zarr.core.buffer.Buffer | None :async: Retrieve the value associated with a given key. :Parameters: **key** : str .. **prototype** : BufferPrototype The prototype of the output buffer. Stores may support a default buffer prototype. **byte_range** : ByteRequest, optional ByteRequest may be one of the following. If not provided, all data associated with the key is retrieved. - RangeByteRequest(int, int): Request a specific range of bytes in the form (start, end). The end is exclusive. If the given range is zero-length or starts after the end of the object, an error will be returned. Additionally, if the range ends after the end of the object, the entire remainder of the object will be returned. Otherwise, the exact requested range will be returned. - OffsetByteRequest(int): Request all bytes starting from a given byte offset. This is equivalent to bytes={int}- as an HTTP header. - SuffixByteRequest(int): Request the last int bytes. Note that here, int is the size of the request, not the byte offset. This is equivalent to bytes=-{int} as an HTTP header. :Returns: Buffer .. .. !! processed by numpydoc !! .. py:method:: get_partial_values(prototype: zarr.core.buffer.BufferPrototype, key_ranges: collections.abc.Iterable[tuple[str, zarr.abc.store.ByteRequest | None]]) -> list[zarr.core.buffer.Buffer | None] :async: Retrieve possibly partial values from given key_ranges. :Parameters: **prototype** : BufferPrototype The prototype of the output buffer. Stores may support a default buffer prototype. **key_ranges** : Iterable[tuple[str, tuple[int | None, int | None]]] Ordered set of key, range pairs, a key may occur multiple times with different ranges :Returns: list of values, in the order of the key_ranges, may contain null/none for missing keys .. .. !! processed by numpydoc !! .. py:method:: getsize(key: str) -> int :async: Return the size, in bytes, of a value in a Store. :Parameters: **key** : str .. :Returns: **nbytes** : int The size of the value (in bytes). :Raises: FileNotFoundError When the given key does not exist in the store. .. !! processed by numpydoc !! .. py:method:: getsize_prefix(prefix: str) -> int :async: Return the size, in bytes, of all values under a prefix. :Parameters: **prefix** : str The prefix of the directory to measure. :Returns: **nbytes** : int The sum of the sizes of the values in the directory (in bytes). .. seealso:: :obj:`zarr.Array.nbytes_stored` .. :obj:`Store.getsize` .. .. rubric:: Notes ``getsize_prefix`` is just provided as a potentially faster alternative to listing all the keys under a prefix calling :meth:`Store.getsize` on each. In general, ``prefix`` should be the path of an Array or Group in the Store. Implementations may differ on the behavior when some other ``prefix`` is provided. .. !! processed by numpydoc !! .. py:method:: is_empty(prefix: str) -> bool :async: Check if the directory is empty. :Parameters: **prefix** : str Prefix of keys to check. :Returns: bool True if the store is empty, False otherwise. .. !! processed by numpydoc !! .. py:method:: list() -> collections.abc.AsyncIterator[str] :async: Retrieve all keys in the store. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: list_dir(prefix: str) -> collections.abc.AsyncIterator[str] :async: Retrieve all keys and prefixes with a given prefix and which do not contain the character “/” after the given prefix. :Parameters: **prefix** : str .. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: list_prefix(prefix: str) -> collections.abc.AsyncIterator[str] :async: Retrieve all keys in the store that begin with a given prefix. Keys are returned relative to the root of the store. :Parameters: **prefix** : str .. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: open(*args: Any, **kwargs: Any) -> Self :classmethod: :async: Create and open the store. :Parameters: **\*args** : Any Positional arguments to pass to the store constructor. **\*\*kwargs** : Any Keyword arguments to pass to the store constructor. :Returns: Store The opened store instance. .. !! processed by numpydoc !! .. py:method:: set(key: str, value: zarr.core.buffer.Buffer, byte_range: tuple[int, int] | None = None) -> None :async: Store a (key, value) pair. :Parameters: **key** : str .. **value** : Buffer .. .. !! processed by numpydoc !! .. py:method:: set_if_not_exists(key: str, value: zarr.core.buffer.Buffer) -> None :async: Store a key to ``value`` if the key is not already present. :Parameters: **key** : str .. **value** : Buffer .. .. !! processed by numpydoc !! .. py:method:: set_partial_values(key_start_values: collections.abc.Iterable[tuple[str, int, bytes | bytearray | memoryview[int]]]) -> None :abstractmethod: :async: Store values at a given key, starting at byte range_start. :Parameters: **key_start_values** : list[tuple[str, int, BytesLike]] set of key, range_start, values triples, a key may occur multiple times with different range_starts, range_starts (considering the length of the respective values) must not specify overlapping ranges for the same key .. !! processed by numpydoc !! .. py:method:: with_read_only(read_only: bool = False) -> MemoryStore Return a new store with a new read_only setting. The new store points to the same location with the specified new read_only state. The returned Store is not automatically opened, and this store is not automatically closed. :Parameters: **read_only** If True, the store will be created in read-only mode. Defaults to False. :Returns: A new store of the same type with the new read only attribute. .. .. !! processed by numpydoc !! .. py:property:: read_only :type: bool Is the store read-only? .. !! processed by numpydoc !! .. py:property:: supports_consolidated_metadata :type: bool Does the store support consolidated metadata?. If it doesn't an error will be raised on requests to consolidate the metadata. Returning `False` can be useful for stores which implement their own consolidation mechanism outside of the zarr-python implementation. .. !! processed by numpydoc !! .. py:attribute:: supports_deletes :type: bool :value: True Does the store support deletes? .. !! processed by numpydoc !! .. py:attribute:: supports_listing :type: bool :value: True Does the store support listing? .. !! processed by numpydoc !! .. py:attribute:: supports_partial_writes :type: bool :value: True Does the store support partial writes? .. !! processed by numpydoc !! .. py:attribute:: supports_writes :type: bool :value: True Does the store support writes? .. !! processed by numpydoc !! .. py:class:: ObjectStore(store: obstore.store.ObjectStore, *, read_only: bool = False) Bases: :py:obj:`zarr.abc.store.Store` Store that uses obstore for fast read/write from AWS, GCP, Azure. :Parameters: **store** : obstore.store.ObjectStore An obstore store instance that is set up with the proper credentials. **read_only** : bool Whether to open the store in read-only mode. .. warning:: ObjectStore is experimental and subject to API changes without notice. Please raise an issue with any comments/concerns about the store. .. !! processed by numpydoc !! .. py:method:: clear() -> None :async: Clear the store. Remove all keys and values from the store. .. !! processed by numpydoc !! .. py:method:: close() -> None Close the store. .. !! processed by numpydoc !! .. py:method:: delete(key: str) -> None :async: Remove a key from the store :Parameters: **key** : str .. .. !! processed by numpydoc !! .. py:method:: delete_dir(prefix: str) -> None :async: Remove all keys and prefixes in the store that begin with a given prefix. .. !! processed by numpydoc !! .. py:method:: exists(key: str) -> bool :async: Check if a key exists in the store. :Parameters: **key** : str .. :Returns: bool .. .. !! processed by numpydoc !! .. py:method:: get(key: str, prototype: zarr.core.buffer.BufferPrototype, byte_range: zarr.abc.store.ByteRequest | None = None) -> zarr.core.buffer.Buffer | None :async: Retrieve the value associated with a given key. :Parameters: **key** : str .. **prototype** : BufferPrototype The prototype of the output buffer. Stores may support a default buffer prototype. **byte_range** : ByteRequest, optional ByteRequest may be one of the following. If not provided, all data associated with the key is retrieved. - RangeByteRequest(int, int): Request a specific range of bytes in the form (start, end). The end is exclusive. If the given range is zero-length or starts after the end of the object, an error will be returned. Additionally, if the range ends after the end of the object, the entire remainder of the object will be returned. Otherwise, the exact requested range will be returned. - OffsetByteRequest(int): Request all bytes starting from a given byte offset. This is equivalent to bytes={int}- as an HTTP header. - SuffixByteRequest(int): Request the last int bytes. Note that here, int is the size of the request, not the byte offset. This is equivalent to bytes=-{int} as an HTTP header. :Returns: Buffer .. .. !! processed by numpydoc !! .. py:method:: get_partial_values(prototype: zarr.core.buffer.BufferPrototype, key_ranges: collections.abc.Iterable[tuple[str, zarr.abc.store.ByteRequest | None]]) -> list[zarr.core.buffer.Buffer | None] :async: Retrieve possibly partial values from given key_ranges. :Parameters: **prototype** : BufferPrototype The prototype of the output buffer. Stores may support a default buffer prototype. **key_ranges** : Iterable[tuple[str, tuple[int | None, int | None]]] Ordered set of key, range pairs, a key may occur multiple times with different ranges :Returns: list of values, in the order of the key_ranges, may contain null/none for missing keys .. .. !! processed by numpydoc !! .. py:method:: getsize(key: str) -> int :async: Return the size, in bytes, of a value in a Store. :Parameters: **key** : str .. :Returns: **nbytes** : int The size of the value (in bytes). :Raises: FileNotFoundError When the given key does not exist in the store. .. !! processed by numpydoc !! .. py:method:: getsize_prefix(prefix: str) -> int :async: Return the size, in bytes, of all values under a prefix. :Parameters: **prefix** : str The prefix of the directory to measure. :Returns: **nbytes** : int The sum of the sizes of the values in the directory (in bytes). .. seealso:: :obj:`zarr.Array.nbytes_stored` .. :obj:`Store.getsize` .. .. rubric:: Notes ``getsize_prefix`` is just provided as a potentially faster alternative to listing all the keys under a prefix calling :meth:`Store.getsize` on each. In general, ``prefix`` should be the path of an Array or Group in the Store. Implementations may differ on the behavior when some other ``prefix`` is provided. .. !! processed by numpydoc !! .. py:method:: is_empty(prefix: str) -> bool :async: Check if the directory is empty. :Parameters: **prefix** : str Prefix of keys to check. :Returns: bool True if the store is empty, False otherwise. .. !! processed by numpydoc !! .. py:method:: list() -> collections.abc.AsyncGenerator[str, None] Retrieve all keys in the store. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: list_dir(prefix: str) -> collections.abc.AsyncGenerator[str, None] Retrieve all keys and prefixes with a given prefix and which do not contain the character “/” after the given prefix. :Parameters: **prefix** : str .. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: list_prefix(prefix: str) -> collections.abc.AsyncGenerator[str, None] Retrieve all keys in the store that begin with a given prefix. Keys are returned relative to the root of the store. :Parameters: **prefix** : str .. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: open(*args: Any, **kwargs: Any) -> Self :classmethod: :async: Create and open the store. :Parameters: **\*args** : Any Positional arguments to pass to the store constructor. **\*\*kwargs** : Any Keyword arguments to pass to the store constructor. :Returns: Store The opened store instance. .. !! processed by numpydoc !! .. py:method:: set(key: str, value: zarr.core.buffer.Buffer) -> None :async: Store a (key, value) pair. :Parameters: **key** : str .. **value** : Buffer .. .. !! processed by numpydoc !! .. py:method:: set_if_not_exists(key: str, value: zarr.core.buffer.Buffer) -> None :async: Store a key to ``value`` if the key is not already present. :Parameters: **key** : str .. **value** : Buffer .. .. !! processed by numpydoc !! .. py:method:: set_partial_values(key_start_values: collections.abc.Iterable[tuple[str, int, zarr.core.common.BytesLike]]) -> None :abstractmethod: :async: Store values at a given key, starting at byte range_start. :Parameters: **key_start_values** : list[tuple[str, int, BytesLike]] set of key, range_start, values triples, a key may occur multiple times with different range_starts, range_starts (considering the length of the respective values) must not specify overlapping ranges for the same key .. !! processed by numpydoc !! .. py:method:: with_read_only(read_only: bool = False) -> ObjectStore Return a new store with a new read_only setting. The new store points to the same location with the specified new read_only state. The returned Store is not automatically opened, and this store is not automatically closed. :Parameters: **read_only** If True, the store will be created in read-only mode. Defaults to False. :Returns: A new store of the same type with the new read only attribute. .. .. !! processed by numpydoc !! .. py:property:: read_only :type: bool Is the store read-only? .. !! processed by numpydoc !! .. py:attribute:: store :type: obstore.store.ObjectStore The underlying obstore instance. .. !! processed by numpydoc !! .. py:property:: supports_consolidated_metadata :type: bool Does the store support consolidated metadata?. If it doesn't an error will be raised on requests to consolidate the metadata. Returning `False` can be useful for stores which implement their own consolidation mechanism outside of the zarr-python implementation. .. !! processed by numpydoc !! .. py:property:: supports_deletes :type: bool Does the store support deletes? .. !! processed by numpydoc !! .. py:property:: supports_listing :type: bool Does the store support listing? .. !! processed by numpydoc !! .. py:property:: supports_partial_writes :type: bool Does the store support partial writes? .. !! processed by numpydoc !! .. py:property:: supports_writes :type: bool Does the store support writes? .. !! processed by numpydoc !! .. py:class:: StorePath(store: zarr.abc.store.Store, path: str = '') Path-like interface for a Store. :Parameters: **store** : Store The store to use. **path** : str The path within the store. .. !! processed by numpydoc !! .. py:method:: delete() -> None :async: Delete the key from the store. :Raises: NotImplementedError If the store does not support deletion. .. !! processed by numpydoc !! .. py:method:: delete_dir() -> None :async: Delete all keys with the given prefix from the store. .. !! processed by numpydoc !! .. py:method:: exists() -> bool :async: Check if the key exists in the store. :Returns: bool True if the key exists in the store, False otherwise. .. !! processed by numpydoc !! .. py:method:: get(prototype: zarr.core.buffer.BufferPrototype | None = None, byte_range: zarr.abc.store.ByteRequest | None = None) -> zarr.core.buffer.Buffer | None :async: Read bytes from the store. :Parameters: **prototype** : BufferPrototype, optional The buffer prototype to use when reading the bytes. **byte_range** : ByteRequest, optional The range of bytes to read. :Returns: **buffer** : Buffer or None The read bytes, or None if the key does not exist. .. !! processed by numpydoc !! .. py:method:: is_empty() -> bool :async: Check if any keys exist in the store with the given prefix. :Returns: bool True if no keys exist in the store with the given prefix, False otherwise. .. !! processed by numpydoc !! .. py:method:: open(store: zarr.abc.store.Store, path: str, mode: zarr.core.common.AccessModeLiteral | None = None) -> Self :classmethod: :async: Open StorePath based on the provided mode. * If the mode is None, return an opened version of the store with no changes. * If the mode is 'r+', 'w-', 'w', or 'a' and the store is read-only, raise a ValueError. * If the mode is 'r' and the store is not read-only, return a copy of the store with read_only set to True. * If the mode is 'w-' and the store is not read-only and the StorePath contains keys, raise a FileExistsError. * If the mode is 'w' and the store is not read-only, delete all keys nested within the StorePath. :Parameters: **mode** : AccessModeLiteral The mode to use when initializing the store path. The accepted values are: - ``'r'``: read only (must exist) - ``'r+'``: read/write (must exist) - ``'a'``: read/write (create if doesn't exist) - ``'w'``: read/write (overwrite if exists) - ``'w-'``: read/write (create if doesn't exist). :Raises: FileExistsError If the mode is 'w-' and the store path already exists. ValueError If the mode is not "r" and the store is read-only, or .. !! processed by numpydoc !! .. py:method:: set(value: zarr.core.buffer.Buffer, byte_range: zarr.abc.store.ByteRequest | None = None) -> None :async: Write bytes to the store. :Parameters: **value** : Buffer The buffer to write. **byte_range** : ByteRequest, optional The range of bytes to write. If None, the entire buffer is written. :Raises: NotImplementedError If `byte_range` is not None, because Store.set does not support partial writes yet. .. !! processed by numpydoc !! .. py:method:: set_if_not_exists(default: zarr.core.buffer.Buffer) -> None :async: Store a key to ``value`` if the key is not already present. :Parameters: **default** : Buffer The buffer to store if the key is not already present. .. !! processed by numpydoc !! .. py:attribute:: path :type: str .. py:property:: read_only :type: bool .. py:attribute:: store :type: zarr.abc.store.Store .. py:class:: WrapperStore(store: T_Store) Bases: :py:obj:`zarr.abc.store.Store`, :py:obj:`Generic`\ [\ :py:obj:`T_Store`\ ] Store that wraps an existing Store. By default all of the store methods are delegated to the wrapped store instance, which is accessible via the ``._store`` attribute of this class. Use this class to modify or extend the behavior of the other store classes. .. !! processed by numpydoc !! .. py:method:: clear() -> None :async: Clear the store. Remove all keys and values from the store. .. !! processed by numpydoc !! .. py:method:: close() -> None Close the store. .. !! processed by numpydoc !! .. py:method:: delete(key: str) -> None :async: Remove a key from the store :Parameters: **key** : str .. .. !! processed by numpydoc !! .. py:method:: delete_dir(prefix: str) -> None :async: Remove all keys and prefixes in the store that begin with a given prefix. .. !! processed by numpydoc !! .. py:method:: exists(key: str) -> bool :async: Check if a key exists in the store. :Parameters: **key** : str .. :Returns: bool .. .. !! processed by numpydoc !! .. py:method:: get(key: str, prototype: zarr.core.buffer.BufferPrototype, byte_range: zarr.abc.store.ByteRequest | None = None) -> zarr.core.buffer.Buffer | None :async: Retrieve the value associated with a given key. :Parameters: **key** : str .. **prototype** : BufferPrototype The prototype of the output buffer. Stores may support a default buffer prototype. **byte_range** : ByteRequest, optional ByteRequest may be one of the following. If not provided, all data associated with the key is retrieved. - RangeByteRequest(int, int): Request a specific range of bytes in the form (start, end). The end is exclusive. If the given range is zero-length or starts after the end of the object, an error will be returned. Additionally, if the range ends after the end of the object, the entire remainder of the object will be returned. Otherwise, the exact requested range will be returned. - OffsetByteRequest(int): Request all bytes starting from a given byte offset. This is equivalent to bytes={int}- as an HTTP header. - SuffixByteRequest(int): Request the last int bytes. Note that here, int is the size of the request, not the byte offset. This is equivalent to bytes=-{int} as an HTTP header. :Returns: Buffer .. .. !! processed by numpydoc !! .. py:method:: get_partial_values(prototype: zarr.core.buffer.BufferPrototype, key_ranges: collections.abc.Iterable[tuple[str, zarr.abc.store.ByteRequest | None]]) -> list[zarr.core.buffer.Buffer | None] :async: Retrieve possibly partial values from given key_ranges. :Parameters: **prototype** : BufferPrototype The prototype of the output buffer. Stores may support a default buffer prototype. **key_ranges** : Iterable[tuple[str, tuple[int | None, int | None]]] Ordered set of key, range pairs, a key may occur multiple times with different ranges :Returns: list of values, in the order of the key_ranges, may contain null/none for missing keys .. .. !! processed by numpydoc !! .. py:method:: getsize(key: str) -> int :async: Return the size, in bytes, of a value in a Store. :Parameters: **key** : str .. :Returns: **nbytes** : int The size of the value (in bytes). :Raises: FileNotFoundError When the given key does not exist in the store. .. !! processed by numpydoc !! .. py:method:: getsize_prefix(prefix: str) -> int :async: Return the size, in bytes, of all values under a prefix. :Parameters: **prefix** : str The prefix of the directory to measure. :Returns: **nbytes** : int The sum of the sizes of the values in the directory (in bytes). .. seealso:: :obj:`zarr.Array.nbytes_stored` .. :obj:`Store.getsize` .. .. rubric:: Notes ``getsize_prefix`` is just provided as a potentially faster alternative to listing all the keys under a prefix calling :meth:`Store.getsize` on each. In general, ``prefix`` should be the path of an Array or Group in the Store. Implementations may differ on the behavior when some other ``prefix`` is provided. .. !! processed by numpydoc !! .. py:method:: is_empty(prefix: str) -> bool :async: Check if the directory is empty. :Parameters: **prefix** : str Prefix of keys to check. :Returns: bool True if the store is empty, False otherwise. .. !! processed by numpydoc !! .. py:method:: list() -> collections.abc.AsyncIterator[str] Retrieve all keys in the store. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: list_dir(prefix: str) -> collections.abc.AsyncIterator[str] Retrieve all keys and prefixes with a given prefix and which do not contain the character “/” after the given prefix. :Parameters: **prefix** : str .. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: list_prefix(prefix: str) -> collections.abc.AsyncIterator[str] Retrieve all keys in the store that begin with a given prefix. Keys are returned relative to the root of the store. :Parameters: **prefix** : str .. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: open(store_cls: type[T_Store], *args: Any, **kwargs: Any) -> Self :classmethod: :async: Create and open the store. :Parameters: **\*args** : Any Positional arguments to pass to the store constructor. **\*\*kwargs** : Any Keyword arguments to pass to the store constructor. :Returns: Store The opened store instance. .. !! processed by numpydoc !! .. py:method:: set(key: str, value: zarr.core.buffer.Buffer) -> None :async: Store a (key, value) pair. :Parameters: **key** : str .. **value** : Buffer .. .. !! processed by numpydoc !! .. py:method:: set_if_not_exists(key: str, value: zarr.core.buffer.Buffer) -> None :async: Store a key to ``value`` if the key is not already present. :Parameters: **key** : str .. **value** : Buffer .. .. !! processed by numpydoc !! .. py:method:: set_partial_values(key_start_values: collections.abc.Iterable[tuple[str, int, zarr.core.common.BytesLike]]) -> None :async: Store values at a given key, starting at byte range_start. :Parameters: **key_start_values** : list[tuple[str, int, BytesLike]] set of key, range_start, values triples, a key may occur multiple times with different range_starts, range_starts (considering the length of the respective values) must not specify overlapping ranges for the same key .. !! processed by numpydoc !! .. py:method:: with_read_only(read_only: bool = False) -> Store :abstractmethod: Return a new store with a new read_only setting. The new store points to the same location with the specified new read_only state. The returned Store is not automatically opened, and this store is not automatically closed. :Parameters: **read_only** If True, the store will be created in read-only mode. Defaults to False. :Returns: A new store of the same type with the new read only attribute. .. .. !! processed by numpydoc !! .. py:property:: read_only :type: bool Is the store read-only? .. !! processed by numpydoc !! .. py:property:: supports_consolidated_metadata :type: bool Does the store support consolidated metadata?. If it doesn't an error will be raised on requests to consolidate the metadata. Returning `False` can be useful for stores which implement their own consolidation mechanism outside of the zarr-python implementation. .. !! processed by numpydoc !! .. py:property:: supports_deletes :type: bool Does the store support deletes? .. !! processed by numpydoc !! .. py:property:: supports_listing :type: bool Does the store support listing? .. !! processed by numpydoc !! .. py:property:: supports_partial_writes :type: bool Does the store support partial writes? .. !! processed by numpydoc !! .. py:property:: supports_writes :type: bool Does the store support writes? .. !! processed by numpydoc !! .. py:class:: ZipStore(path: pathlib.Path | str, *, mode: ZipStoreAccessModeLiteral = 'r', read_only: bool | None = None, compression: int = zipfile.ZIP_STORED, allowZip64: bool = True) Bases: :py:obj:`zarr.abc.store.Store` Store using a ZIP file. :Parameters: **path** : str Location of file. **mode** : str, optional One of 'r' to read an existing file, 'w' to truncate and write a new file, 'a' to append to an existing file, or 'x' to exclusively create and write a new file. **compression** : int, optional Compression method to use when writing to the archive. **allowZip64** : bool, optional If True (the default) will create ZIP files that use the ZIP64 extensions when the zipfile is larger than 2 GiB. If False will raise an exception when the ZIP file would require ZIP64 extensions. :Attributes: **allowed_exceptions** .. **supports_writes** .. **supports_deletes** .. **supports_partial_writes** .. **supports_listing** .. **path** .. **compression** .. **allowZip64** .. .. !! processed by numpydoc !! .. py:method:: clear() -> None :async: Clear the store. Remove all keys and values from the store. .. !! processed by numpydoc !! .. py:method:: close() -> None Close the store. .. !! processed by numpydoc !! .. py:method:: delete(key: str) -> None :async: Remove a key from the store :Parameters: **key** : str .. .. !! processed by numpydoc !! .. py:method:: delete_dir(prefix: str) -> None :async: Remove all keys and prefixes in the store that begin with a given prefix. .. !! processed by numpydoc !! .. py:method:: exists(key: str) -> bool :async: Check if a key exists in the store. :Parameters: **key** : str .. :Returns: bool .. .. !! processed by numpydoc !! .. py:method:: get(key: str, prototype: zarr.core.buffer.BufferPrototype, byte_range: zarr.abc.store.ByteRequest | None = None) -> zarr.core.buffer.Buffer | None :async: Retrieve the value associated with a given key. :Parameters: **key** : str .. **prototype** : BufferPrototype The prototype of the output buffer. Stores may support a default buffer prototype. **byte_range** : ByteRequest, optional ByteRequest may be one of the following. If not provided, all data associated with the key is retrieved. - RangeByteRequest(int, int): Request a specific range of bytes in the form (start, end). The end is exclusive. If the given range is zero-length or starts after the end of the object, an error will be returned. Additionally, if the range ends after the end of the object, the entire remainder of the object will be returned. Otherwise, the exact requested range will be returned. - OffsetByteRequest(int): Request all bytes starting from a given byte offset. This is equivalent to bytes={int}- as an HTTP header. - SuffixByteRequest(int): Request the last int bytes. Note that here, int is the size of the request, not the byte offset. This is equivalent to bytes=-{int} as an HTTP header. :Returns: Buffer .. .. !! processed by numpydoc !! .. py:method:: get_partial_values(prototype: zarr.core.buffer.BufferPrototype, key_ranges: collections.abc.Iterable[tuple[str, zarr.abc.store.ByteRequest | None]]) -> list[zarr.core.buffer.Buffer | None] :async: Retrieve possibly partial values from given key_ranges. :Parameters: **prototype** : BufferPrototype The prototype of the output buffer. Stores may support a default buffer prototype. **key_ranges** : Iterable[tuple[str, tuple[int | None, int | None]]] Ordered set of key, range pairs, a key may occur multiple times with different ranges :Returns: list of values, in the order of the key_ranges, may contain null/none for missing keys .. .. !! processed by numpydoc !! .. py:method:: getsize(key: str) -> int :async: Return the size, in bytes, of a value in a Store. :Parameters: **key** : str .. :Returns: **nbytes** : int The size of the value (in bytes). :Raises: FileNotFoundError When the given key does not exist in the store. .. !! processed by numpydoc !! .. py:method:: getsize_prefix(prefix: str) -> int :async: Return the size, in bytes, of all values under a prefix. :Parameters: **prefix** : str The prefix of the directory to measure. :Returns: **nbytes** : int The sum of the sizes of the values in the directory (in bytes). .. seealso:: :obj:`zarr.Array.nbytes_stored` .. :obj:`Store.getsize` .. .. rubric:: Notes ``getsize_prefix`` is just provided as a potentially faster alternative to listing all the keys under a prefix calling :meth:`Store.getsize` on each. In general, ``prefix`` should be the path of an Array or Group in the Store. Implementations may differ on the behavior when some other ``prefix`` is provided. .. !! processed by numpydoc !! .. py:method:: is_empty(prefix: str) -> bool :async: Check if the directory is empty. :Parameters: **prefix** : str Prefix of keys to check. :Returns: bool True if the store is empty, False otherwise. .. !! processed by numpydoc !! .. py:method:: list() -> collections.abc.AsyncIterator[str] :async: Retrieve all keys in the store. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: list_dir(prefix: str) -> collections.abc.AsyncIterator[str] :async: Retrieve all keys and prefixes with a given prefix and which do not contain the character “/” after the given prefix. :Parameters: **prefix** : str .. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: list_prefix(prefix: str) -> collections.abc.AsyncIterator[str] :async: Retrieve all keys in the store that begin with a given prefix. Keys are returned relative to the root of the store. :Parameters: **prefix** : str .. :Returns: AsyncIterator[str] .. .. !! processed by numpydoc !! .. py:method:: move(path: pathlib.Path | str) -> None :async: Move the store to another path. .. !! processed by numpydoc !! .. py:method:: open(*args: Any, **kwargs: Any) -> Self :classmethod: :async: Create and open the store. :Parameters: **\*args** : Any Positional arguments to pass to the store constructor. **\*\*kwargs** : Any Keyword arguments to pass to the store constructor. :Returns: Store The opened store instance. .. !! processed by numpydoc !! .. py:method:: set(key: str, value: zarr.core.buffer.Buffer) -> None :async: Store a (key, value) pair. :Parameters: **key** : str .. **value** : Buffer .. .. !! processed by numpydoc !! .. py:method:: set_if_not_exists(key: str, value: zarr.core.buffer.Buffer) -> None :async: Store a key to ``value`` if the key is not already present. :Parameters: **key** : str .. **value** : Buffer .. .. !! processed by numpydoc !! .. py:method:: set_partial_values(key_start_values: collections.abc.Iterable[tuple[str, int, bytes | bytearray | memoryview[int]]]) -> None :abstractmethod: :async: Store values at a given key, starting at byte range_start. :Parameters: **key_start_values** : list[tuple[str, int, BytesLike]] set of key, range_start, values triples, a key may occur multiple times with different range_starts, range_starts (considering the length of the respective values) must not specify overlapping ranges for the same key .. !! processed by numpydoc !! .. py:method:: with_read_only(read_only: bool = False) -> Store :abstractmethod: Return a new store with a new read_only setting. The new store points to the same location with the specified new read_only state. The returned Store is not automatically opened, and this store is not automatically closed. :Parameters: **read_only** If True, the store will be created in read-only mode. Defaults to False. :Returns: A new store of the same type with the new read only attribute. .. .. !! processed by numpydoc !! .. py:attribute:: allowZip64 :type: bool .. py:attribute:: compression :type: int .. py:attribute:: path :type: pathlib.Path .. py:property:: read_only :type: bool Is the store read-only? .. !! processed by numpydoc !! .. py:property:: supports_consolidated_metadata :type: bool Does the store support consolidated metadata?. If it doesn't an error will be raised on requests to consolidate the metadata. Returning `False` can be useful for stores which implement their own consolidation mechanism outside of the zarr-python implementation. .. !! processed by numpydoc !! .. py:attribute:: supports_deletes :type: bool :value: False Does the store support deletes? .. !! processed by numpydoc !! .. py:attribute:: supports_listing :type: bool :value: True Does the store support listing? .. !! processed by numpydoc !! .. py:attribute:: supports_partial_writes :type: bool :value: False Does the store support partial writes? .. !! processed by numpydoc !! .. py:attribute:: supports_writes :type: bool :value: True Does the store support writes? .. !! processed by numpydoc !! .. py:data:: StoreLike :type: TypeAlias :value: Store | StorePath | FSMap | Path | str | dict[str, Buffer]