Skip to content
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

V3 reorg #1809

Merged
merged 4 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ API reference
api/codecs
api/attrs
api/sync
api/v3

Indices and tables
------------------
Expand Down
6 changes: 3 additions & 3 deletions docs/api/attrs.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The Attributes class (``zarr.attrs``)
=====================================
.. module:: zarr.attrs
The Attributes class (``zarr.v2.attrs``)
========================================
.. module:: zarr.v2.attrs

.. autoclass:: Attributes

Expand Down
8 changes: 4 additions & 4 deletions docs/api/codecs.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Compressors and filters (``zarr.codecs``)
=========================================
Compressors and filters (``zarr.v2.codecs``)
============================================
.. module:: zarr.codecs

This module contains compressor and filter classes for use with Zarr. Please note that this module
Expand All @@ -8,9 +8,9 @@ onwards, all codec classes have been moved to a separate package called Numcodec
packages (Zarr and Numcodecs_) are designed to be used together. For example, a Numcodecs_ codec
class can be used as a compressor for a Zarr array::

>>> import zarr
>>> import zarr.v2
>>> from numcodecs import Blosc
>>> z = zarr.zeros(1000000, compressor=Blosc(cname='zstd', clevel=1, shuffle=Blosc.SHUFFLE))
>>> z = zarr.v2.zeros(1000000, compressor=Blosc(cname='zstd', clevel=1, shuffle=Blosc.SHUFFLE))

Codec classes can also be used as filters. See the tutorial section on :ref:`tutorial_filters`
for more information.
Expand Down
6 changes: 3 additions & 3 deletions docs/api/convenience.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Convenience functions (``zarr.convenience``)
============================================
.. automodule:: zarr.convenience
Convenience functions (``zarr.v2.convenience``)
===============================================
.. automodule:: zarr.v2.convenience
.. autofunction:: open
.. autofunction:: save
.. autofunction:: load
Expand Down
6 changes: 3 additions & 3 deletions docs/api/core.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The Array class (``zarr.core``)
===============================
The Array class (``zarr.v2.core``)
==================================

.. automodapi:: zarr.core
.. automodapi:: zarr.v2.core
:no-heading:
6 changes: 3 additions & 3 deletions docs/api/creation.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Array creation (``zarr.creation``)
==================================
.. module:: zarr.creation
Array creation (``zarr.v2.creation``)
=====================================
.. module:: zarr.v2.creation
.. autofunction:: create
.. autofunction:: empty
.. autofunction:: zeros
Expand Down
6 changes: 3 additions & 3 deletions docs/api/hierarchy.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Groups (``zarr.hierarchy``)
===========================
.. module:: zarr.hierarchy
Groups (``zarr.v2.hierarchy``)
==============================
.. module:: zarr.v2.hierarchy

.. autofunction:: group
.. autofunction:: open_group
Expand Down
6 changes: 3 additions & 3 deletions docs/api/n5.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
N5 (``zarr.n5``)
================
.. automodule:: zarr.n5
N5 (``zarr.v2.n5``)
===================
.. automodule:: zarr.v2.n5

.. autoclass:: N5Store
6 changes: 3 additions & 3 deletions docs/api/storage.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Storage (``zarr.storage``)
==========================
.. automodule:: zarr.storage
Storage (``zarr.v2.storage``)
=============================
.. automodule:: zarr.v2.storage

.. autoclass:: MemoryStore
.. autoclass:: DirectoryStore
Expand Down
6 changes: 3 additions & 3 deletions docs/api/sync.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Synchronization (``zarr.sync``)
===============================
.. module:: zarr.sync
Synchronization (``zarr.v2.sync``)
==================================
.. module:: zarr.v2.sync

.. autoclass:: ThreadSynchronizer
.. autoclass:: ProcessSynchronizer
77 changes: 0 additions & 77 deletions docs/api/v3.rst

This file was deleted.

42 changes: 23 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ docs = [
'pydata-sphinx-theme',
'numpydoc',
'numcodecs[msgpack]',
"msgpack",
"lmdb",
"zstandard",
"crc32c",
]
extra = [
'attrs',
Expand Down Expand Up @@ -164,31 +168,31 @@ disallow_any_generics = true

[[tool.mypy.overrides]]
module = [
"zarr._storage.store",
"zarr._storage.v3_storage_transformers",
"zarr.v3.group",
"zarr.core",
"zarr.hierarchy",
"zarr.indexing",
"zarr.storage",
"zarr.sync",
"zarr.util",
"zarr.v2._storage.store",
"zarr.v2._storage.v3_storage_transformers",
"zarr.group",
"zarr.v2.core",
"zarr.v2.hierarchy",
"zarr.v2.indexing",
"zarr.v2.storage",
"zarr.v2.sync",
"zarr.v2.util",
"tests.*",
]
check_untyped_defs = false

[[tool.mypy.overrides]]
module = [
"zarr.v3.abc.codec",
"zarr.v3.codecs.bytes",
"zarr.v3.codecs.pipeline",
"zarr.v3.codecs.sharding",
"zarr.v3.codecs.transpose",
"zarr.v3.array_v2",
"zarr.v3.array",
"zarr.v3.sync",
"zarr.convenience",
"zarr.meta",
"zarr.abc.codec",
"zarr.codecs.bytes",
"zarr.codecs.pipeline",
"zarr.codecs.sharding",
"zarr.codecs.transpose",
"zarr.array_v2",
"zarr.array",
"zarr.sync",
"zarr.v2.convenience",
"zarr.v2.meta",
]
disallow_any_generics = false

Expand Down
91 changes: 39 additions & 52 deletions src/zarr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,41 @@
# flake8: noqa
from zarr.codecs import *
from zarr.convenience import (
consolidate_metadata,
copy,
copy_all,
copy_store,
load,
open,
open_consolidated,
save,
save_array,
save_group,
tree,
)
from zarr.core import Array
from zarr.creation import (
array,
create,
empty,
empty_like,
full,
full_like,
ones,
ones_like,
open_array,
open_like,
zeros,
zeros_like,
)
from zarr.errors import CopyError, MetadataError
from zarr.hierarchy import Group, group, open_group
from zarr.n5 import N5Store, N5FSStore
from zarr.storage import (
ABSStore,
DBMStore,
DictStore,
DirectoryStore,
KVStore,
LMDBStore,
LRUStoreCache,
MemoryStore,
MongoDBStore,
NestedDirectoryStore,
RedisStore,
SQLiteStore,
TempStore,
ZipStore,
from __future__ import annotations

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is showing up as a line-edit diff but no edits were made. I first moved the original __init__.py -> v2/__init__.py, then made a commit. Then the v3/__init__.py file was moved here in a second commit.

from typing import Union

import zarr.codecs # noqa: F401
from zarr.array import Array, AsyncArray # noqa: F401
from zarr.array_v2 import ArrayV2
from zarr.config import RuntimeConfiguration # noqa: F401
from zarr.group import AsyncGroup, Group # noqa: F401
from zarr.metadata import runtime_configuration # noqa: F401
from zarr.store import ( # noqa: F401
StoreLike,
make_store_path,
)
from zarr.sync import ProcessSynchronizer, ThreadSynchronizer
from zarr._version import version as __version__
from zarr.sync import sync as _sync


async def open_auto_async(
store: StoreLike,
runtime_configuration_: RuntimeConfiguration = RuntimeConfiguration(),
) -> Union[AsyncArray, AsyncGroup]:
store_path = make_store_path(store)
try:
return await AsyncArray.open(store_path, runtime_configuration=runtime_configuration_)
except KeyError:
return await AsyncGroup.open(store_path, runtime_configuration=runtime_configuration_)


# in case setuptools scm screw up and find version to be 0.0.0
assert not __version__.startswith("0.0.0")
def open_auto(
store: StoreLike,
runtime_configuration_: RuntimeConfiguration = RuntimeConfiguration(),
) -> Union[Array, ArrayV2, Group]:
object = _sync(
open_auto_async(store, runtime_configuration_),
runtime_configuration_.asyncio_loop,
)
if isinstance(object, AsyncArray):
return Array(object)
if isinstance(object, AsyncGroup):
return Group(object)
raise TypeError(f"Unexpected object type. Got {type(object)}.")
File renamed without changes.
12 changes: 6 additions & 6 deletions src/zarr/v3/abc/codec.py → src/zarr/abc/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
from typing import TYPE_CHECKING, Optional

import numpy as np
from zarr.v3.abc.metadata import Metadata
from zarr.abc.metadata import Metadata

from zarr.v3.common import ArraySpec
from zarr.v3.store import StorePath
from zarr.common import ArraySpec
from zarr.store import StorePath


if TYPE_CHECKING:
from typing_extensions import Self
from zarr.v3.common import BytesLike, SliceSelection
from zarr.v3.metadata import ArrayMetadata
from zarr.v3.config import RuntimeConfiguration
from zarr.common import BytesLike, SliceSelection
from zarr.metadata import ArrayMetadata
from zarr.config import RuntimeConfiguration


class Codec(Metadata):
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/v3/abc/metadata.py → src/zarr/abc/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from dataclasses import fields, dataclass

from zarr.v3.common import JSON
from zarr.common import JSON


@dataclass(frozen=True)
Expand Down
File renamed without changes.
Loading
Loading