From 91a0341f88d0cbd6908f342a1fa8689f4526bffe Mon Sep 17 00:00:00 2001 From: zyzhao Date: Thu, 3 Dec 2026 16:56:53 +0800 Subject: [PATCH 1/9] fix: return None for missing keys in LocalStore batch reads --- src/zarr/storage/_local.py | 7 ++----- tests/test_store/test_local.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/zarr/storage/_local.py b/src/zarr/storage/_local.py index 20d4b102b1..bbee5d6776 100644 --- a/src/zarr/storage/_local.py +++ b/src/zarr/storage/_local.py @@ -364,11 +364,8 @@ async def get_partial_values( key_ranges: Iterable[tuple[str, ByteRequest | None]], ) -> list[Buffer | None]: # docstring inherited - args = [] - for key, byte_range in key_ranges: - path = self.root / key - args.append((_get, path, prototype, byte_range)) - return await concurrent_map(args, asyncio.to_thread, limit=None) # TODO: fix limit + args = ((key, prototype, byte_range) for key, byte_range in key_ranges) + return await concurrent_map(args, self.get, limit=None) # TODO: fix limit async def set(self, key: str, value: Buffer) -> None: # docstring inherited diff --git a/tests/test_store/test_local.py b/tests/test_store/test_local.py index 8e7cc5279a..4864f96987 100644 --- a/tests/test_store/test_local.py +++ b/tests/test_store/test_local.py @@ -16,6 +16,7 @@ import zarr import zarr.storage._local from zarr import create_array +from zarr.abc.store import RangeByteRequest from zarr.core.buffer import Buffer, cpu from zarr.storage import LocalStore from zarr.storage._local import _RETRY_DELAYS, _atomic_write, _move_with_retry @@ -199,6 +200,18 @@ async def test_filesystem_calls_are_observed( await ops[method]() assert helper in {function for function, _ in filesystem_calls.off_loop} + async def test_get_partial_values_with_missing_key(self, store: LocalStore) -> None: + await store.set("chunk", self.buffer_cls.from_bytes(b"NAME")) + values = await store.get_partial_values( + cpu.buffer_prototype, + [ + ("chunk", RangeByteRequest(0, 2)), + ("missing", None), + ("chunk", RangeByteRequest(2, 4)), + ], + ) + assert [v.to_bytes() if v is not None else None for v in values] == [b"NA", None, b"ME"] + async def test_concurrent_lazy_open(self, store_not_open: LocalStore) -> None: """Concurrent first calls on an unopened store all succeed. From f0d6288ebac971bedba7951877e0d77e988e2709 Mon Sep 17 00:00:00 2001 From: zyzhao Date: Thu, 3 Dec 2026 16:57:48 +0800 Subject: [PATCH 2/9] docs: add changelog entry for fork PR 1 --- changes/1.bugfix.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/1.bugfix.md diff --git a/changes/1.bugfix.md b/changes/1.bugfix.md new file mode 100644 index 0000000000..9f6b50b08b --- /dev/null +++ b/changes/1.bugfix.md @@ -0,0 +1 @@ +LocalStore.get_partial_values() now returns `None` for each missing key and returns the requested byte ranges for the other entries in order. From eefca8e0c2636ff964aa4e91885fd33a71556380 Mon Sep 17 00:00:00 2001 From: zyzhao Date: Thu, 3 Dec 2026 17:17:56 +0800 Subject: [PATCH 3/9] fix: avoid opening LocalStore during batch reads --- src/zarr/storage/_local.py | 26 ++++++++++++-------------- tests/test_store/test_local.py | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/zarr/storage/_local.py b/src/zarr/storage/_local.py index bbee5d6776..4d22d47d1d 100644 --- a/src/zarr/storage/_local.py +++ b/src/zarr/storage/_local.py @@ -28,7 +28,7 @@ from zarr.core.buffer import BufferPrototype -def _get(path: Path, prototype: BufferPrototype, byte_range: ByteRequest | None) -> Buffer: +def _read_file(path: Path, prototype: BufferPrototype, byte_range: ByteRequest | None) -> Buffer: if byte_range is None: return prototype.buffer.from_bytes(path.read_bytes()) with path.open("rb") as f: @@ -45,6 +45,13 @@ def _get(path: Path, prototype: BufferPrototype, byte_range: ByteRequest | None) return prototype.buffer.from_bytes(f.read()) +def _get(path: Path, prototype: BufferPrototype, byte_range: ByteRequest | None) -> Buffer | None: + try: + return _read_file(path, prototype, byte_range) + except (FileNotFoundError, IsADirectoryError, NotADirectoryError): + return None + + if sys.platform == "win32": # Per the os.rename docs: # On Windows, if dst exists a FileExistsError is always raised. @@ -319,11 +326,7 @@ def get_sync( if prototype is None: prototype = default_buffer_prototype() self._ensure_open_sync() - path = self.root / key - try: - return _get(path, prototype, byte_range) - except (FileNotFoundError, IsADirectoryError, NotADirectoryError): - return None + return _get(self.root / key, prototype, byte_range) def set_sync(self, key: str, value: Buffer) -> None: self._ensure_open_sync() @@ -351,12 +354,7 @@ async def get( if prototype is None: prototype = default_buffer_prototype() await self._ensure_open() - path = self.root / key - - try: - return await asyncio.to_thread(_get, path, prototype, byte_range) - except (FileNotFoundError, IsADirectoryError, NotADirectoryError): - return None + return await asyncio.to_thread(_get, self.root / key, prototype, byte_range) async def get_partial_values( self, @@ -364,8 +362,8 @@ async def get_partial_values( key_ranges: Iterable[tuple[str, ByteRequest | None]], ) -> list[Buffer | None]: # docstring inherited - args = ((key, prototype, byte_range) for key, byte_range in key_ranges) - return await concurrent_map(args, self.get, limit=None) # TODO: fix limit + args = ((_get, self.root / key, prototype, byte_range) for key, byte_range in key_ranges) + return await concurrent_map(args, asyncio.to_thread, limit=None) # TODO: fix limit async def set(self, key: str, value: Buffer) -> None: # docstring inherited diff --git a/tests/test_store/test_local.py b/tests/test_store/test_local.py index 4864f96987..c371d4758f 100644 --- a/tests/test_store/test_local.py +++ b/tests/test_store/test_local.py @@ -212,6 +212,24 @@ async def test_get_partial_values_with_missing_key(self, store: LocalStore) -> N ) assert [v.to_bytes() if v is not None else None for v in values] == [b"NA", None, b"ME"] + async def test_get_partial_values_leaves_missing_root_absent( + self, tmp_path: pathlib.Path + ) -> None: + root = tmp_path / "store" + store = LocalStore(root) + assert await store.get_partial_values(cpu.buffer_prototype, [("missing", None)]) == [None] + assert not root.exists() + + async def test_get_partial_values_propagates_permission_error( + self, store: LocalStore, monkeypatch: pytest.MonkeyPatch + ) -> None: + def deny_read(path: pathlib.Path) -> bytes: + raise PermissionError(path) + + monkeypatch.setattr(pathlib.Path, "read_bytes", deny_read) + with pytest.raises(PermissionError): + await store.get_partial_values(cpu.buffer_prototype, [("key", None)]) + async def test_concurrent_lazy_open(self, store_not_open: LocalStore) -> None: """Concurrent first calls on an unopened store all succeed. From 8d644acbfdfc4d85c83c9e04cd812f87f026fe45 Mon Sep 17 00:00:00 2001 From: zyzhao Date: Thu, 3 Dec 2026 20:16:44 +0800 Subject: [PATCH 4/9] fix: handle directory reads and consume batch input before scheduling --- src/zarr/storage/_local.py | 9 +++++++- tests/test_store/test_local.py | 39 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/zarr/storage/_local.py b/src/zarr/storage/_local.py index 4d22d47d1d..dc32ee7338 100644 --- a/src/zarr/storage/_local.py +++ b/src/zarr/storage/_local.py @@ -50,6 +50,12 @@ def _get(path: Path, prototype: BufferPrototype, byte_range: ByteRequest | None) return _read_file(path, prototype, byte_range) except (FileNotFoundError, IsADirectoryError, NotADirectoryError): return None + except PermissionError: + # Opening a directory on Windows can report access denied. + with contextlib.suppress(OSError): + if path.is_dir(): + return None + raise if sys.platform == "win32": @@ -362,7 +368,8 @@ async def get_partial_values( key_ranges: Iterable[tuple[str, ByteRequest | None]], ) -> list[Buffer | None]: # docstring inherited - args = ((_get, self.root / key, prototype, byte_range) for key, byte_range in key_ranges) + # Consume the iterable before scheduling reads in case it raises partway through. + args = [(_get, self.root / key, prototype, byte_range) for key, byte_range in key_ranges] return await concurrent_map(args, asyncio.to_thread, limit=None) # TODO: fix limit async def set(self, key: str, value: Buffer) -> None: diff --git a/tests/test_store/test_local.py b/tests/test_store/test_local.py index c371d4758f..87a9a58a01 100644 --- a/tests/test_store/test_local.py +++ b/tests/test_store/test_local.py @@ -6,9 +6,11 @@ import os import pathlib import re +import sys import time from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any +from unittest.mock import AsyncMock import numpy as np import pytest @@ -223,6 +225,8 @@ async def test_get_partial_values_leaves_missing_root_absent( async def test_get_partial_values_propagates_permission_error( self, store: LocalStore, monkeypatch: pytest.MonkeyPatch ) -> None: + await store.set("key", self.buffer_cls.from_bytes(b"private")) + def deny_read(path: pathlib.Path) -> bytes: raise PermissionError(path) @@ -230,6 +234,41 @@ def deny_read(path: pathlib.Path) -> bytes: with pytest.raises(PermissionError): await store.get_partial_values(cpu.buffer_prototype, [("key", None)]) + async def test_get_partial_values_directory_and_child( + self, store: LocalStore, monkeypatch: pytest.MonkeyPatch + ) -> None: + await store.set("group/chunk", self.buffer_cls.from_bytes(b"data")) + if sys.platform != "win32": + # Windows denies opening directories for reading. Exercise that error on POSIX too. + read_bytes = pathlib.Path.read_bytes + + def windows_read_bytes(path: pathlib.Path) -> bytes: + if path == store.root / "group": + raise PermissionError(path) + return read_bytes(path) + + monkeypatch.setattr(pathlib.Path, "read_bytes", windows_read_bytes) + + directory, child = await store.get_partial_values( + cpu.buffer_prototype, [("group", None), ("group/chunk", None)] + ) + assert directory is None + assert child is not None and child.to_bytes() == b"data" + + async def test_get_partial_values_invalid_iterable_schedules_no_reads( + self, store: LocalStore, monkeypatch: pytest.MonkeyPatch + ) -> None: + def key_ranges() -> Iterator[tuple[str, None]]: + yield "first", None + raise ValueError("invalid range sequence") + + to_thread = AsyncMock() + monkeypatch.setattr(asyncio, "to_thread", to_thread) + with pytest.raises(ValueError, match="invalid range sequence"): + await store.get_partial_values(cpu.buffer_prototype, key_ranges()) + await asyncio.sleep(0) # Give any abandoned tasks a chance to start. + to_thread.assert_not_called() + async def test_concurrent_lazy_open(self, store_not_open: LocalStore) -> None: """Concurrent first calls on an unopened store all succeed. From 5fde3eb877179f7981bbd1d252f07336c5972fd4 Mon Sep 17 00:00:00 2001 From: zyzhao Date: Thu, 3 Dec 2026 23:25:27 +0800 Subject: [PATCH 5/9] fix: report invalid LocalStore roots on batch read misses --- src/zarr/storage/_local.py | 22 ++++++++++++++++++++-- tests/test_store/test_local.py | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/zarr/storage/_local.py b/src/zarr/storage/_local.py index dc32ee7338..7921d1a54c 100644 --- a/src/zarr/storage/_local.py +++ b/src/zarr/storage/_local.py @@ -2,9 +2,11 @@ import asyncio import contextlib +import errno import io import os import shutil +import stat import sys import time import uuid @@ -156,6 +158,16 @@ def _ensure_root(root: Path, *, create: bool) -> None: raise FileNotFoundError(f"{root} does not exist") +def _check_batch_root(root: Path) -> None: + """Distinguish missing keys from an existing root that cannot contain keys.""" + try: + mode = root.stat().st_mode + except FileNotFoundError: + return + if not stat.S_ISDIR(mode): + raise NotADirectoryError(errno.ENOTDIR, os.strerror(errno.ENOTDIR), root) + + def _clear(root: Path) -> None: shutil.rmtree(root) root.mkdir() @@ -369,8 +381,14 @@ async def get_partial_values( ) -> list[Buffer | None]: # docstring inherited # Consume the iterable before scheduling reads in case it raises partway through. - args = [(_get, self.root / key, prototype, byte_range) for key, byte_range in key_ranges] - return await concurrent_map(args, asyncio.to_thread, limit=None) # TODO: fix limit + root = self.root + args = [(_get, root / key, prototype, byte_range) for key, byte_range in key_ranges] + values: list[Buffer | None] = await concurrent_map( + args, asyncio.to_thread, limit=None # TODO: fix limit + ) + if any(value is None for value in values): + await asyncio.to_thread(_check_batch_root, root) + return values async def set(self, key: str, value: Buffer) -> None: # docstring inherited diff --git a/tests/test_store/test_local.py b/tests/test_store/test_local.py index 87a9a58a01..d2596de93b 100644 --- a/tests/test_store/test_local.py +++ b/tests/test_store/test_local.py @@ -222,6 +222,25 @@ async def test_get_partial_values_leaves_missing_root_absent( assert await store.get_partial_values(cpu.buffer_prototype, [("missing", None)]) == [None] assert not root.exists() + async def test_get_partial_values_replaced_root(self, tmp_path: pathlib.Path) -> None: + root = tmp_path / "store" + store = await LocalStore.open(root) + root.rename(tmp_path / "original") + root.write_bytes(b"not a directory") + + with pytest.raises(NotADirectoryError): + await store.get_partial_values( + cpu.buffer_prototype, [("first", None), ("second", None)] + ) + + async def test_get_partial_values_file_as_key_prefix(self, store: LocalStore) -> None: + await store.set("prefix", self.buffer_cls.from_bytes(b"data")) + child, value = await store.get_partial_values( + cpu.buffer_prototype, [("prefix/child", None), ("prefix", None)] + ) + assert child is None + assert value is not None and value.to_bytes() == b"data" + async def test_get_partial_values_propagates_permission_error( self, store: LocalStore, monkeypatch: pytest.MonkeyPatch ) -> None: From 8dc730b18e37f0332702b14416f6c43ade88cbe2 Mon Sep 17 00:00:00 2001 From: zyzhao Date: Thu, 3 Dec 2026 23:33:06 +0800 Subject: [PATCH 6/9] fix: propagate buffer construction errors from LocalStore reads --- src/zarr/storage/_local.py | 11 ++++++----- tests/test_store/test_local.py | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/zarr/storage/_local.py b/src/zarr/storage/_local.py index 7921d1a54c..1acaa8a31a 100644 --- a/src/zarr/storage/_local.py +++ b/src/zarr/storage/_local.py @@ -30,26 +30,26 @@ from zarr.core.buffer import BufferPrototype -def _read_file(path: Path, prototype: BufferPrototype, byte_range: ByteRequest | None) -> Buffer: +def _read_file(path: Path, byte_range: ByteRequest | None) -> bytes: if byte_range is None: - return prototype.buffer.from_bytes(path.read_bytes()) + return path.read_bytes() with path.open("rb") as f: size = f.seek(0, io.SEEK_END) if isinstance(byte_range, RangeByteRequest): f.seek(byte_range.start) - return prototype.buffer.from_bytes(f.read(byte_range.end - f.tell())) + return f.read(byte_range.end - f.tell()) elif isinstance(byte_range, OffsetByteRequest): f.seek(byte_range.offset) elif isinstance(byte_range, SuffixByteRequest): f.seek(max(0, size - byte_range.suffix)) else: raise TypeError(f"Unexpected byte_range, got {byte_range}.") - return prototype.buffer.from_bytes(f.read()) + return f.read() def _get(path: Path, prototype: BufferPrototype, byte_range: ByteRequest | None) -> Buffer | None: try: - return _read_file(path, prototype, byte_range) + data = _read_file(path, byte_range) except (FileNotFoundError, IsADirectoryError, NotADirectoryError): return None except PermissionError: @@ -58,6 +58,7 @@ def _get(path: Path, prototype: BufferPrototype, byte_range: ByteRequest | None) if path.is_dir(): return None raise + return prototype.buffer.from_bytes(data) if sys.platform == "win32": diff --git a/tests/test_store/test_local.py b/tests/test_store/test_local.py index d2596de93b..6fc6d7bdb0 100644 --- a/tests/test_store/test_local.py +++ b/tests/test_store/test_local.py @@ -27,6 +27,9 @@ if TYPE_CHECKING: from collections.abc import AsyncIterator, Awaitable, Callable, Iterator + from typing import Self + + from zarr.core.common import BytesLike _LOCAL_STORE_FILE = zarr.storage._local.__file__ _ASYNC_CODE_FLAGS = inspect.CO_COROUTINE | inspect.CO_ASYNC_GENERATOR @@ -214,6 +217,22 @@ async def test_get_partial_values_with_missing_key(self, store: LocalStore) -> N ) assert [v.to_bytes() if v is not None else None for v in values] == [b"NA", None, b"ME"] + @pytest.mark.parametrize("byte_range", [None, RangeByteRequest(0, 7)]) + async def test_get_partial_values_propagates_buffer_error( + self, store: LocalStore, byte_range: RangeByteRequest | None + ) -> None: + class FileBackedBuffer(cpu.Buffer): + @classmethod + def from_bytes(cls, bytes_like: BytesLike) -> Self: + path = store.root / bytes(bytes_like).decode("ascii") + return super().from_bytes(path.read_bytes()) + + await store.set("chunk", self.buffer_cls.from_bytes(b"backing")) + prototype = cpu.buffer_prototype._replace(buffer=FileBackedBuffer) + with pytest.raises(FileNotFoundError) as exc: + await store.get_partial_values(prototype, [("chunk", byte_range)]) + assert exc.value.filename == str(store.root / "backing") + async def test_get_partial_values_leaves_missing_root_absent( self, tmp_path: pathlib.Path ) -> None: From fd3fcc3396af1bb79dfba5b2ad1f3212096bece1 Mon Sep 17 00:00:00 2001 From: zyzhao Date: Thu, 3 Dec 2026 23:54:58 +0800 Subject: [PATCH 7/9] fix: propagate missing read-only roots during LocalStore batch reads --- src/zarr/storage/_local.py | 12 ++++++++---- tests/test_store/test_local.py | 30 ++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/zarr/storage/_local.py b/src/zarr/storage/_local.py index 1acaa8a31a..31314736c5 100644 --- a/src/zarr/storage/_local.py +++ b/src/zarr/storage/_local.py @@ -159,11 +159,13 @@ def _ensure_root(root: Path, *, create: bool) -> None: raise FileNotFoundError(f"{root} does not exist") -def _check_batch_root(root: Path) -> None: - """Distinguish missing keys from an existing root that cannot contain keys.""" +def _check_batch_root(root: Path, *, read_only: bool) -> None: + """A writable root may be absent until the first write.""" try: mode = root.stat().st_mode except FileNotFoundError: + if read_only: + raise return if not stat.S_ISDIR(mode): raise NotADirectoryError(errno.ENOTDIR, os.strerror(errno.ENOTDIR), root) @@ -385,10 +387,12 @@ async def get_partial_values( root = self.root args = [(_get, root / key, prototype, byte_range) for key, byte_range in key_ranges] values: list[Buffer | None] = await concurrent_map( - args, asyncio.to_thread, limit=None # TODO: fix limit + args, + asyncio.to_thread, + limit=None, # TODO: fix limit ) if any(value is None for value in values): - await asyncio.to_thread(_check_batch_root, root) + await asyncio.to_thread(_check_batch_root, root, read_only=self.read_only) return values async def set(self, key: str, value: Buffer) -> None: diff --git a/tests/test_store/test_local.py b/tests/test_store/test_local.py index 6fc6d7bdb0..67d6225235 100644 --- a/tests/test_store/test_local.py +++ b/tests/test_store/test_local.py @@ -241,6 +241,30 @@ async def test_get_partial_values_leaves_missing_root_absent( assert await store.get_partial_values(cpu.buffer_prototype, [("missing", None)]) == [None] assert not root.exists() + async def test_get_partial_values_missing_read_only_root(self, tmp_path: pathlib.Path) -> None: + root = tmp_path / "store" + store = LocalStore(root, read_only=True) + with pytest.raises(FileNotFoundError) as exc: + await store.get_partial_values(cpu.buffer_prototype, [("chunk", None)]) + assert exc.value.filename == str(root) + assert not root.exists() + + async def test_get_partial_values_renamed_read_only_root(self, tmp_path: pathlib.Path) -> None: + root = tmp_path / "store" + root.mkdir() + (root / "chunk").write_bytes(b"data") + store = await LocalStore.open(root, read_only=True) + keys = [("chunk", None), ("missing", None)] + chunk, missing = await store.get_partial_values(cpu.buffer_prototype, keys) + assert chunk is not None + assert chunk.to_bytes() == b"data" + assert missing is None + + root.rename(tmp_path / "moved") + with pytest.raises(FileNotFoundError) as exc: + await store.get_partial_values(cpu.buffer_prototype, keys) + assert exc.value.filename == str(root) + async def test_get_partial_values_replaced_root(self, tmp_path: pathlib.Path) -> None: root = tmp_path / "store" store = await LocalStore.open(root) @@ -258,7 +282,8 @@ async def test_get_partial_values_file_as_key_prefix(self, store: LocalStore) -> cpu.buffer_prototype, [("prefix/child", None), ("prefix", None)] ) assert child is None - assert value is not None and value.to_bytes() == b"data" + assert value is not None + assert value.to_bytes() == b"data" async def test_get_partial_values_propagates_permission_error( self, store: LocalStore, monkeypatch: pytest.MonkeyPatch @@ -291,7 +316,8 @@ def windows_read_bytes(path: pathlib.Path) -> bytes: cpu.buffer_prototype, [("group", None), ("group/chunk", None)] ) assert directory is None - assert child is not None and child.to_bytes() == b"data" + assert child is not None + assert child.to_bytes() == b"data" async def test_get_partial_values_invalid_iterable_schedules_no_reads( self, store: LocalStore, monkeypatch: pytest.MonkeyPatch From a414136597f9159dbbf456de3d8c6408d5429cf7 Mon Sep 17 00:00:00 2001 From: zyzhao Date: Sat, 5 Dec 2026 12:49:17 +0800 Subject: [PATCH 8/9] fix: require the root for batch reads on an open LocalStore --- src/zarr/storage/_local.py | 9 +++++---- tests/test_store/test_local.py | 7 +++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/zarr/storage/_local.py b/src/zarr/storage/_local.py index 31314736c5..912d2cf421 100644 --- a/src/zarr/storage/_local.py +++ b/src/zarr/storage/_local.py @@ -159,12 +159,12 @@ def _ensure_root(root: Path, *, create: bool) -> None: raise FileNotFoundError(f"{root} does not exist") -def _check_batch_root(root: Path, *, read_only: bool) -> None: - """A writable root may be absent until the first write.""" +def _check_batch_root(root: Path, *, require_root: bool) -> None: + """Only an unopened writable store may have a missing root.""" try: mode = root.stat().st_mode except FileNotFoundError: - if read_only: + if require_root: raise return if not stat.S_ISDIR(mode): @@ -385,6 +385,7 @@ async def get_partial_values( # docstring inherited # Consume the iterable before scheduling reads in case it raises partway through. root = self.root + require_root = self._is_open or self.read_only args = [(_get, root / key, prototype, byte_range) for key, byte_range in key_ranges] values: list[Buffer | None] = await concurrent_map( args, @@ -392,7 +393,7 @@ async def get_partial_values( limit=None, # TODO: fix limit ) if any(value is None for value in values): - await asyncio.to_thread(_check_batch_root, root, read_only=self.read_only) + await asyncio.to_thread(_check_batch_root, root, require_root=require_root) return values async def set(self, key: str, value: Buffer) -> None: diff --git a/tests/test_store/test_local.py b/tests/test_store/test_local.py index 67d6225235..df3ca118ef 100644 --- a/tests/test_store/test_local.py +++ b/tests/test_store/test_local.py @@ -249,11 +249,14 @@ async def test_get_partial_values_missing_read_only_root(self, tmp_path: pathlib assert exc.value.filename == str(root) assert not root.exists() - async def test_get_partial_values_renamed_read_only_root(self, tmp_path: pathlib.Path) -> None: + @pytest.mark.parametrize("read_only", [False, True], ids=["writable", "read-only"]) + async def test_get_partial_values_renamed_open_root( + self, tmp_path: pathlib.Path, read_only: bool + ) -> None: root = tmp_path / "store" root.mkdir() (root / "chunk").write_bytes(b"data") - store = await LocalStore.open(root, read_only=True) + store = await LocalStore.open(root, read_only=read_only) keys = [("chunk", None), ("missing", None)] chunk, missing = await store.get_partial_values(cpu.buffer_prototype, keys) assert chunk is not None From dc5c8a563c98d5f835bcae708f516d294deaca9d Mon Sep 17 00:00:00 2001 From: zyzhao Date: Sat, 5 Dec 2026 14:05:15 +0800 Subject: [PATCH 9/9] docs: use upstream PR number for LocalStore changelog entry --- changes/{1.bugfix.md => 4707.bugfix.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changes/{1.bugfix.md => 4707.bugfix.md} (100%) diff --git a/changes/1.bugfix.md b/changes/4707.bugfix.md similarity index 100% rename from changes/1.bugfix.md rename to changes/4707.bugfix.md