Skip to content

Commit a39bd7d

Browse files
committed
Add codec_pipeline.fill_missing_chunks config
1 parent 6811c94 commit a39bd7d

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/zarr/core/codec_pipeline.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from zarr.core.common import concurrent_map
1818
from zarr.core.config import config
1919
from zarr.core.indexing import SelectorTuple, is_scalar
20-
from zarr.errors import ZarrUserWarning
20+
from zarr.errors import MissingChunkError, ZarrUserWarning
2121
from zarr.registry import register_pipeline
2222

2323
if TYPE_CHECKING:
@@ -265,7 +265,10 @@ async def read_batch(
265265
if chunk_array is not None:
266266
out[out_selection] = chunk_array
267267
else:
268-
out[out_selection] = fill_value_or_default(chunk_spec)
268+
if config.get("codec_pipeline.fill_missing_chunks", True):
269+
out[out_selection] = fill_value_or_default(chunk_spec)
270+
else:
271+
raise MissingChunkError()
269272
else:
270273
chunk_bytes_batch = await concurrent_map(
271274
[(byte_getter, array_spec.prototype) for byte_getter, array_spec, *_ in batch_info],
@@ -289,7 +292,10 @@ async def read_batch(
289292
tmp = tmp.squeeze(axis=drop_axes)
290293
out[out_selection] = tmp
291294
else:
292-
out[out_selection] = fill_value_or_default(chunk_spec)
295+
if config.get("codec_pipeline.fill_missing_chunks", True):
296+
out[out_selection] = fill_value_or_default(chunk_spec)
297+
else:
298+
raise MissingChunkError()
293299

294300
def _merge_chunk_array(
295301
self,

src/zarr/errors.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,6 @@ class BoundsCheckError(IndexError): ...
144144

145145

146146
class ArrayIndexError(IndexError): ...
147+
148+
149+
class MissingChunkError(IndexError): ...

0 commit comments

Comments
 (0)