Skip to content

Commit ee30347

Browse files
authored
Feature: Top level V3 API (#1884)
* feature(api): add top level synchronous and asynchronous api * add group/open_group * minor doc improvement * sync with v3 branch * fix mypy errors * progress integrating store mode * basic tests are passing * docs and missing store utils file * fix parse shapelike test * fix bad merge * respond to reviews
1 parent 661acb3 commit ee30347

File tree

17 files changed

+2167
-64
lines changed

17 files changed

+2167
-64
lines changed

src/zarr/__init__.py

Lines changed: 61 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,68 @@
1-
from __future__ import annotations
2-
3-
import zarr.codecs # noqa: F401
41
from zarr._version import version as __version__
2+
from zarr.api.synchronous import (
3+
array,
4+
consolidate_metadata,
5+
copy,
6+
copy_all,
7+
copy_store,
8+
create,
9+
empty,
10+
empty_like,
11+
full,
12+
full_like,
13+
group,
14+
load,
15+
ones,
16+
ones_like,
17+
open,
18+
open_array,
19+
open_consolidated,
20+
open_group,
21+
open_like,
22+
save,
23+
save_array,
24+
save_group,
25+
tree,
26+
zeros,
27+
zeros_like,
28+
)
529
from zarr.array import Array, AsyncArray
6-
from zarr.config import config # noqa: F401
30+
from zarr.config import config
731
from zarr.group import AsyncGroup, Group
8-
from zarr.store import (
9-
StoreLike,
10-
make_store_path,
11-
)
12-
from zarr.sync import sync as _sync
1332

1433
# in case setuptools scm screw up and find version to be 0.0.0
1534
assert not __version__.startswith("0.0.0")
1635

17-
18-
async def open_auto_async(store: StoreLike) -> AsyncArray | AsyncGroup:
19-
store_path = make_store_path(store)
20-
try:
21-
return await AsyncArray.open(store_path)
22-
except KeyError:
23-
return await AsyncGroup.open(store_path)
24-
25-
26-
def open_auto(store: StoreLike) -> Array | Group:
27-
object = _sync(
28-
open_auto_async(store),
29-
)
30-
if isinstance(object, AsyncArray):
31-
return Array(object)
32-
if isinstance(object, AsyncGroup):
33-
return Group(object)
34-
raise TypeError(f"Unexpected object type. Got {type(object)}.")
36+
__all__ = [
37+
"__version__",
38+
"config",
39+
"Array",
40+
"AsyncArray",
41+
"Group",
42+
"AsyncGroup",
43+
"tree",
44+
"array",
45+
"consolidate_metadata",
46+
"copy",
47+
"copy_all",
48+
"copy_store",
49+
"create",
50+
"empty",
51+
"empty_like",
52+
"full",
53+
"full_like",
54+
"group",
55+
"load",
56+
"ones",
57+
"ones_like",
58+
"open",
59+
"open_array",
60+
"open_consolidated",
61+
"open_group",
62+
"open_like",
63+
"save",
64+
"save_array",
65+
"save_group",
66+
"zeros",
67+
"zeros_like",
68+
]

src/zarr/api/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)