Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into feature/slim-zarr
  • Loading branch information
jhamman committed Oct 17, 2024
2 parents 002b805 + 4d663cc commit 5daa82a
Show file tree
Hide file tree
Showing 14 changed files with 311 additions and 147 deletions.
52 changes: 27 additions & 25 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ maintainers = [
{ name = "Juan Nunez-Iglesias", email = "juan.nunez-iglesias@monash.edu" },
{ name = "Martin Durant", email = "mdurant@anaconda.com" },
{ name = "Norman Rzepka" },
{ name = "Ryan Abernathey" }
{ name = "Ryan Abernathey" },
{ name = "David Stansby" },
{ name = "Tom Augspurger", email = "tom.w.augspurger@gmail.com" },
{ name = "Deepak Cherian" }
]
requires-python = ">=3.11"
# If you add a new dependency here, please also add it to .pre-commit-config.yml
dependencies = [
'numpy>=1.25',
'numcodecs>=0.12',
'typing_extensions',
'donfig',
'typing_extensions>=4.9',
'donfig>=0.8.1',
]
dynamic = [
"version",
Expand All @@ -49,10 +52,10 @@ keywords = ["Python", "compressed", "ndimensional-arrays", "zarr"]

[project.optional-dependencies]
remote = [
"fsspec",
"fsspec>=2023.10.0",
]
sharding = [
"crc32c",
"crc32c>=2.4",
]
test = [
"coverage",
Expand Down Expand Up @@ -205,34 +208,33 @@ extend-exclude = [

[tool.ruff.lint]
extend-select = [
"ANN", # flake8-annotations
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"FLY", # flynt
"G", # flake8-logging-format
"I", # isort
"ISC", # flake8-implicit-str-concat
"PGH", # pygrep-hooks
"PT", # flake8-pytest-style
"PYI", # flake8-pyi
"RSE", # flake8-raise
"RET", # flake8-return
"ANN", # flake8-annotations
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"FLY", # flynt
"G", # flake8-logging-format
"I", # isort
"ISC", # flake8-implicit-str-concat
"PERF", # Perflint
"PGH", # pygrep-hooks
"PT", # flake8-pytest-style
"PYI", # flake8-pyi
"RSE", # flake8-raise
"RET", # flake8-return
"RUF",
"TCH", # flake8-type-checking
"TRY", # tryceratops
"UP", # pyupgrade
"W", # pycodestyle warnings
"TCH", # flake8-type-checking
"TRY", # tryceratops
"UP", # pyupgrade
"W", # pycodestyle warnings
]
ignore = [
"ANN003",
"ANN101",
"ANN102",
"ANN101", # deprecated
"ANN102", # deprecated
"ANN401",
"PT004", # deprecated
"PT005", # deprecated
"PT011", # TODO: apply this rule
"PT012", # TODO: apply this rule
"PYI013",
"RET505",
"RET506",
"RUF005",
Expand Down
6 changes: 0 additions & 6 deletions src/zarr/abc/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,14 @@ async def encode(
class ArrayArrayCodec(BaseCodec[NDBuffer, NDBuffer]):
"""Base class for array-to-array codecs."""

...


class ArrayBytesCodec(BaseCodec[NDBuffer, Buffer]):
"""Base class for array-to-bytes codecs."""

...


class BytesBytesCodec(BaseCodec[Buffer, Buffer]):
"""Base class for bytes-to-bytes codecs."""

...


Codec = ArrayArrayCodec | ArrayBytesCodec | BytesBytesCodec

Expand Down
33 changes: 9 additions & 24 deletions src/zarr/api/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,7 @@ async def consolidate_metadata(
The group, with the ``consolidated_metadata`` field set to include
the metadata of each child node.
"""
store_path = await make_store_path(store)

if path is not None:
store_path = store_path / path
store_path = await make_store_path(store, path=path)

group = await AsyncGroup.open(store_path, zarr_format=zarr_format, use_consolidated=False)
group.store_path.store._check_writable()
Expand Down Expand Up @@ -291,10 +288,7 @@ async def open(
"""
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)

store_path = await make_store_path(store, mode=mode, storage_options=storage_options)

if path is not None:
store_path = store_path / path
store_path = await make_store_path(store, mode=mode, path=path, storage_options=storage_options)

if "shape" not in kwargs and mode in {"a", "w", "w-"}:
try:
Expand Down Expand Up @@ -401,9 +395,7 @@ async def save_array(
)

mode = kwargs.pop("mode", None)
store_path = await make_store_path(store, mode=mode, storage_options=storage_options)
if path is not None:
store_path = store_path / path
store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)
new = await AsyncArray.create(
store_path,
zarr_format=zarr_format,
Expand Down Expand Up @@ -582,9 +574,7 @@ async def group(

mode = None if isinstance(store, Store) else cast(AccessModeLiteral, "a")

store_path = await make_store_path(store, mode=mode, storage_options=storage_options)
if path is not None:
store_path = store_path / path
store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)

if chunk_store is not None:
warnings.warn("chunk_store is not yet implemented", RuntimeWarning, stacklevel=2)
Expand Down Expand Up @@ -697,9 +687,7 @@ async def open_group(
if chunk_store is not None:
warnings.warn("chunk_store is not yet implemented", RuntimeWarning, stacklevel=2)

store_path = await make_store_path(store, mode=mode, storage_options=storage_options)
if path is not None:
store_path = store_path / path
store_path = await make_store_path(store, mode=mode, storage_options=storage_options, path=path)

if attributes is None:
attributes = {}
Expand Down Expand Up @@ -883,9 +871,7 @@ async def create(
if not isinstance(store, Store | StorePath):
mode = "a"

store_path = await make_store_path(store, mode=mode, storage_options=storage_options)
if path is not None:
store_path = store_path / path
store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)

return await AsyncArray.create(
store_path,
Expand Down Expand Up @@ -925,6 +911,7 @@ async def empty(
retrieve data from an empty Zarr array, any values may be returned,
and these are not guaranteed to be stable from one access to the next.
"""

return await create(shape=shape, fill_value=None, **kwargs)


Expand Down Expand Up @@ -1044,7 +1031,7 @@ async def open_array(
store: StoreLike | None = None,
zarr_version: ZarrFormat | None = None, # deprecated
zarr_format: ZarrFormat | None = None,
path: PathLike | None = None,
path: PathLike = "",
storage_options: dict[str, Any] | None = None,
**kwargs: Any, # TODO: type kwargs as valid args to save
) -> AsyncArray[ArrayV2Metadata] | AsyncArray[ArrayV3Metadata]:
Expand All @@ -1071,9 +1058,7 @@ async def open_array(
"""

mode = kwargs.pop("mode", None)
store_path = await make_store_path(store, mode=mode)
if path is not None:
store_path = store_path / path
store_path = await make_store_path(store, path=path, mode=mode)

zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)

Expand Down
8 changes: 1 addition & 7 deletions src/zarr/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -2873,13 +2873,7 @@ def chunks_initialized(
store_contents = list(
collect_aiterator(array.store_path.store.list_prefix(prefix=array.store_path.path))
)
out: list[str] = []

for chunk_key in array._iter_chunk_keys():
if chunk_key in store_contents:
out.append(chunk_key)

return tuple(out)
return tuple(chunk_key for chunk_key in array._iter_chunk_keys() if chunk_key in store_contents)


def _build_parents(
Expand Down
Loading

0 comments on commit 5daa82a

Please sign in to comment.