Skip to content

Commit

Permalink
Merge branch 'main' into some-utils-typing
Browse files Browse the repository at this point in the history
  • Loading branch information
dstansby authored Mar 6, 2024
2 parents 84b2f20 + 240bb82 commit daea474
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 30 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ contact_links:
- name: ✨ Propose a new major feature
url: https://github.com/zarr-developers/zarr-specs
about: A new major feature should be discussed in the Zarr specifications repository.
- name: ❓ Discuss something on gitter
url: https://gitter.im/zarr-developers/community
about: For questions like "How do I do X with Zarr?", you can move to our Gitter channel.
- name: ❓ Discuss something on Zulip
url: https://ossci.zulipchat.com/
about: For questions like "How do I do X with Zarr?", you can move to our Zulip Chat.
- name: ❓ Discuss something on GitHub Discussions
url: https://github.com/zarr-developers/zarr-python/discussions
about: For questions like "How do I do X with Zarr?", you can move to GitHub Discussions.
2 changes: 1 addition & 1 deletion .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
with:
name: releases
path: dist
- uses: pypa/gh-action-pypi-publish@v1.8.11
- uses: pypa/gh-action-pypi-publish@v1.8.12
with:
user: __token__
password: ${{ secrets.pypi_password }}
Expand Down
4 changes: 3 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ python:
extra_requirements:
- docs

formats: all
formats:
- htmlzip
- pdf
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@
</td>
</tr>
<tr>
<td>Gitter</td>
<td>Zulip</td>
<td>
<a href="https://gitter.im/zarr-developers/community">
<img src="https://badges.gitter.im/zarr-developers/community.svg" />
<a href="https://ossci.zulipchat.com/">
<img src="https://img.shields.io/badge/zulip-join_chat-brightgreen.svg" />
</a>
</td>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ Zarr-Python

**Version**: |version|

**Download documentation**: `PDF/Zipped HTML/EPUB <https://readthedocs.org/projects/zarr/downloads/>`_
**Download documentation**: `PDF/Zipped HTML <https://readthedocs.org/projects/zarr/downloads/>`_

**Useful links**:
`Installation <installation.html>`_ |
`Source Repository <https://github.com/zarr-developers/zarr-python>`_ |
`Issue Tracker <https://github.com/zarr-developers/zarr-python/issues>`_ |
`Gitter <https://gitter.im/zarr-developers/community>`_
`Zulip Chat <https://ossci.zulipchat.com/>`_

Zarr is a file storage format for chunked, compressed, N-dimensional arrays based on an open-source specification.

Expand Down
4 changes: 2 additions & 2 deletions requirements_dev_optional.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ ipywidgets==8.1.2
# don't let pyup change pinning for azure-storage-blob, need to pin to older
# version to get compatibility with azure storage emulator on appveyor (FIXME)
azure-storage-blob==12.16.0 # pyup: ignore
redis==5.0.1
redis==5.0.2
types-redis
types-setuptools
pymongo==4.6.2
# optional test requirements
coverage
pytest-cov==4.1.0
pytest-doctestplus==1.1.0
pytest-doctestplus==1.2.0
pytest-timeout==2.2.0
h5py==3.10.0
fsspec==2023.12.2
Expand Down
5 changes: 4 additions & 1 deletion zarr/_storage/absstore.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
"""This module contains storage classes related to Azure Blob Storage (ABS)"""

from typing import Optional
import warnings

from numcodecs.compat import ensure_bytes
from zarr.util import normalize_storage_path
from zarr._storage.store import _get_metadata_suffix, data_root, meta_root, Store, StoreV3
from zarr.types import DIMENSION_SEPARATOR

__doctest_requires__ = {
("ABSStore", "ABSStore.*"): ["azure.storage.blob"],
Expand Down Expand Up @@ -67,7 +70,7 @@ def __init__(
account_name=None,
account_key=None,
blob_service_kwargs=None,
dimension_separator=None,
dimension_separator: Optional[DIMENSION_SEPARATOR] = None,
client=None,
):
self._dimension_separator = dimension_separator
Expand Down
7 changes: 5 additions & 2 deletions zarr/_storage/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
from collections import OrderedDict
from collections.abc import MutableMapping
from threading import Lock
from typing import Union, Dict, Any
from typing import Union, Dict, Any, Optional

from zarr.errors import (
MetadataError,
ReadOnlyError,
)
from zarr.util import buffer_size, json_loads, normalize_storage_path
from zarr.types import DIMENSION_SEPARATOR

from zarr._storage.absstore import ABSStoreV3 # noqa: F401
from zarr._storage.store import ( # noqa: F401
Expand Down Expand Up @@ -224,7 +225,9 @@ def get_partial_values(self, key_ranges):


class MemoryStoreV3(MemoryStore, StoreV3):
def __init__(self, root=None, cls=dict, dimension_separator=None):
def __init__(
self, root=None, cls=dict, dimension_separator: Optional[DIMENSION_SEPARATOR] = None
):
if root is None:
self.root = cls()
else:
Expand Down
3 changes: 2 additions & 1 deletion zarr/_storage/v3_storage_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from zarr._storage.store import StorageTransformer, StoreV3, _rmdir_from_keys_v3
from zarr.util import normalize_storage_path
from zarr.types import DIMENSION_SEPARATOR


MAX_UINT_64 = 2**64 - 1
Expand Down Expand Up @@ -118,7 +119,7 @@ def _copy_for_array(self, array, inner_store):
return transformer_copy

@property
def dimension_separator(self) -> str:
def dimension_separator(self) -> DIMENSION_SEPARATOR:
assert (
self._dimension_separator is not None
), "dimension_separator is not initialized, first get a copy via _copy_for_array."
Expand Down
2 changes: 1 addition & 1 deletion zarr/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def open_array(
write_empty_chunks=True,
*,
zarr_version=None,
dimension_separator=None,
dimension_separator: Optional[DIMENSION_SEPARATOR] = None,
meta_array=None,
**kwargs,
):
Expand Down
45 changes: 32 additions & 13 deletions zarr/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
from numcodecs.compat import ensure_bytes, ensure_text, ensure_contiguous_ndarray_like
from numcodecs.registry import codec_registry
from zarr.context import Context
from zarr.types import PathLike as Path
from zarr.types import PathLike as Path, DIMENSION_SEPARATOR
from zarr.util import NoLock

from zarr.errors import (
MetadataError,
Expand Down Expand Up @@ -327,7 +328,7 @@ def init_array(
chunk_store: Optional[StoreLike] = None,
filters=None,
object_codec=None,
dimension_separator=None,
dimension_separator: Optional[DIMENSION_SEPARATOR] = None,
storage_transformers=(),
):
"""Initialize an array store with the given configuration. Note that this is a low-level
Expand Down Expand Up @@ -481,7 +482,7 @@ def _init_array_metadata(
chunk_store: Optional[StoreLike] = None,
filters=None,
object_codec=None,
dimension_separator=None,
dimension_separator: Optional[DIMENSION_SEPARATOR] = None,
storage_transformers=(),
):
store_version = getattr(store, "_store_version", 2)
Expand Down Expand Up @@ -1054,7 +1055,9 @@ class DirectoryStore(Store):
"""

def __init__(self, path, normalize_keys=False, dimension_separator=None):
def __init__(
self, path, normalize_keys=False, dimension_separator: Optional[DIMENSION_SEPARATOR] = None
):
# guard conditions
path = os.path.abspath(path)
if os.path.exists(path) and not os.path.isdir(path):
Expand Down Expand Up @@ -1349,7 +1352,7 @@ def __init__(
key_separator=None,
mode="w",
exceptions=(KeyError, PermissionError, IOError),
dimension_separator=None,
dimension_separator: Optional[DIMENSION_SEPARATOR] = None,
fs=None,
check=False,
create=False,
Expand Down Expand Up @@ -1568,7 +1571,12 @@ class TempStore(DirectoryStore):

# noinspection PyShadowingBuiltins
def __init__(
self, suffix="", prefix="zarr", dir=None, normalize_keys=False, dimension_separator=None
self,
suffix="",
prefix="zarr",
dir=None,
normalize_keys=False,
dimension_separator: Optional[DIMENSION_SEPARATOR] = None,
):
path = tempfile.mkdtemp(suffix=suffix, prefix=prefix, dir=dir)
atexit.register(atexit_rmtree, path)
Expand Down Expand Up @@ -1652,7 +1660,9 @@ class NestedDirectoryStore(DirectoryStore):
"""

def __init__(self, path, normalize_keys=False, dimension_separator="/"):
def __init__(
self, path, normalize_keys=False, dimension_separator: Optional[DIMENSION_SEPARATOR] = "/"
):
super().__init__(path, normalize_keys=normalize_keys)
if dimension_separator is None:
dimension_separator = "/"
Expand Down Expand Up @@ -1765,7 +1775,7 @@ def __init__(
compression=zipfile.ZIP_STORED,
allowZip64=True,
mode="a",
dimension_separator=None,
dimension_separator: Optional[DIMENSION_SEPARATOR] = None,
):
# store properties
path = os.path.abspath(path)
Expand Down Expand Up @@ -2058,7 +2068,7 @@ def __init__(
mode=0o666,
open=None,
write_lock=True,
dimension_separator=None,
dimension_separator: Optional[DIMENSION_SEPARATOR] = None,
**open_kwargs,
):
if open is None:
Expand All @@ -2073,6 +2083,7 @@ def __init__(
self.mode = mode
self.open = open
self.write_lock = write_lock
self.write_mutex: Union[Lock, NoLock]
if write_lock:
# This may not be required as some dbm implementations manage their own
# locks, but err on the side of caution.
Expand Down Expand Up @@ -2229,7 +2240,13 @@ class LMDBStore(Store):
"""

def __init__(self, path, buffers=True, dimension_separator=None, **kwargs):
def __init__(
self,
path,
buffers=True,
dimension_separator: Optional[DIMENSION_SEPARATOR] = None,
**kwargs,
):
import lmdb

# set default memory map size to something larger than the lmdb default, which is
Expand Down Expand Up @@ -2580,7 +2597,7 @@ class SQLiteStore(Store):
>>> store.close() # don't forget to call this when you're done
"""

def __init__(self, path, dimension_separator=None, **kwargs):
def __init__(self, path, dimension_separator: Optional[DIMENSION_SEPARATOR] = None, **kwargs):
import sqlite3

self._dimension_separator = dimension_separator
Expand Down Expand Up @@ -2776,7 +2793,7 @@ def __init__(
self,
database="mongodb_zarr",
collection="zarr_collection",
dimension_separator=None,
dimension_separator: Optional[DIMENSION_SEPARATOR] = None,
**kwargs,
):
import pymongo
Expand Down Expand Up @@ -2851,7 +2868,9 @@ class RedisStore(Store):
"""

def __init__(self, prefix="zarr", dimension_separator=None, **kwargs):
def __init__(
self, prefix="zarr", dimension_separator: Optional[DIMENSION_SEPARATOR] = None, **kwargs
):
import redis

self._prefix = prefix
Expand Down

0 comments on commit daea474

Please sign in to comment.