Skip to content

Commit eff01ce

Browse files
authored
Merge branch 'v3' into doc/storage
2 parents a78461e + 979b6f2 commit eff01ce

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/zarr/storage/local.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ def __init__(self, root: Path | str, *, mode: AccessModeLiteral = "r") -> None:
100100
assert isinstance(root, Path)
101101
self.root = root
102102

103+
async def _open(self) -> None:
104+
if not self.mode.readonly:
105+
self.root.mkdir(parents=True, exist_ok=True)
106+
return await super()._open()
107+
103108
async def clear(self) -> None:
104109
# docstring inherited
105110
self._check_writable()

tests/v3/test_store/test_local.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
from __future__ import annotations
22

3+
from typing import TYPE_CHECKING
4+
35
import pytest
46

7+
import zarr
58
from zarr.core.buffer import Buffer, cpu
69
from zarr.storage.local import LocalStore
710
from zarr.testing.store import StoreTests
811

12+
if TYPE_CHECKING:
13+
import pathlib
14+
915

1016
class TestLocalStore(StoreTests[LocalStore, cpu.Buffer]):
1117
store_cls = LocalStore
@@ -40,3 +46,10 @@ async def test_empty_with_empty_subdir(self, store: LocalStore) -> None:
4046
assert await store.empty()
4147
(store.root / "foo/bar").mkdir(parents=True)
4248
assert await store.empty()
49+
50+
def test_creates_new_directory(self, tmp_path: pathlib.Path):
51+
target = tmp_path.joinpath("a", "b", "c")
52+
assert not target.exists()
53+
54+
store = self.store_cls(root=target, mode="w")
55+
zarr.group(store=store)

0 commit comments

Comments
 (0)