Skip to content

Commit 204dda1

Browse files
committed
prune dead code, make protocols useful
1 parent 6996284 commit 204dda1

4 files changed

Lines changed: 13 additions & 55 deletions

File tree

src/zarr/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
from zarr.core.array import Array, AsyncArray
3838
from zarr.core.config import config
3939
from zarr.core.group import AsyncGroup, Group
40-
from zarr.experimental.sync_codecs import SyncCodecPipeline # noqa: F401 (backwards compat)
4140

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

src/zarr/core/array.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import zarr
2626
from zarr.abc.codec import ArrayArrayCodec, ArrayBytesCodec, BytesBytesCodec, Codec
2727
from zarr.abc.numcodec import Numcodec, _is_numcodec
28+
from zarr.abc.store import SyncByteGetter
2829
from zarr.codecs._v2 import V2Codec
2930
from zarr.codecs.bytes import BytesCodec
3031
from zarr.codecs.vlen_utf8 import VLenBytesCodec, VLenUTF8Codec
@@ -1982,8 +1983,9 @@ def _can_use_sync_path(self) -> bool:
19821983
implement ``SupportsSyncCodec``). This is True for
19831984
BatchedCodecPipeline when all codecs support sync.
19841985
1985-
2. The store supports synchronous operations (has ``get_sync``).
1986-
MemoryStore and LocalStore provide this; remote stores do not.
1986+
2. The store supports synchronous operations (implements
1987+
``SyncByteGetter``). MemoryStore and LocalStore provide this;
1988+
remote stores do not.
19871989
19881990
When both hold, the selection methods below call
19891991
_get_selection_sync / _set_selection_sync directly, running the
@@ -1993,7 +1995,7 @@ def _can_use_sync_path(self) -> bool:
19931995
"""
19941996
pipeline = self.async_array.codec_pipeline
19951997
store = self.async_array.store_path.store
1996-
return getattr(pipeline, "supports_sync_io", False) and hasattr(store, "get_sync")
1998+
return getattr(pipeline, "supports_sync_io", False) and isinstance(store, SyncByteGetter)
19971999

19982000
@classmethod
19992001
@deprecated("Use zarr.create_array instead.", category=ZarrDeprecationWarning)
@@ -3088,8 +3090,8 @@ def get_basic_selection(
30883090
prototype=prototype,
30893091
)
30903092
# Fallback: submit the async coroutine to the background event loop
3091-
# thread via sync(). Used for remote stores, sharded arrays, or when
3092-
# SyncCodecPipeline is not active.
3093+
# thread via sync(). Used for remote stores or when the sync bypass
3094+
# is not active.
30933095
return sync(
30943096
self.async_array._get_selection(
30953097
indexer,

src/zarr/experimental/sync_codecs.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

tests/test_sync_codec_pipeline.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -297,18 +297,9 @@ def test_supports_sync_io(self) -> None:
297297
pipeline = BatchedCodecPipeline.from_codecs([BytesCodec(), GzipCodec(level=1)])
298298
assert pipeline.supports_sync_io
299299

300-
def test_config_switch_to_sync_pipeline_compat(self) -> None:
301-
"""Verify backwards compat: SyncCodecPipeline config path still works."""
302-
from zarr.experimental.sync_codecs import SyncCodecPipeline
303-
304-
zarr.config.set({"codec_pipeline.path": "zarr.experimental.sync_codecs.SyncCodecPipeline"})
305-
try:
306-
store = MemoryStore()
307-
arr = zarr.create_array(store, shape=(10,), dtype="float64")
308-
assert isinstance(arr.async_array.codec_pipeline, SyncCodecPipeline)
309-
# SyncCodecPipeline is-a BatchedCodecPipeline
310-
assert isinstance(arr.async_array.codec_pipeline, BatchedCodecPipeline)
311-
finally:
312-
zarr.config.set(
313-
{"codec_pipeline.path": "zarr.core.codec_pipeline.BatchedCodecPipeline"}
314-
)
300+
def test_supports_sync_io_default(self) -> None:
301+
"""Default BatchedCodecPipeline is the sync pipeline — no config switch needed."""
302+
store = MemoryStore()
303+
arr = zarr.create_array(store, shape=(10,), dtype="float64")
304+
assert isinstance(arr.async_array.codec_pipeline, BatchedCodecPipeline)
305+
assert arr.async_array.codec_pipeline.supports_sync_io

0 commit comments

Comments
 (0)