1717from zarr .core .common import concurrent_map
1818from zarr .core .config import config
1919from zarr .core .indexing import SelectorTuple , is_scalar
20- from zarr .errors import MissingChunkError , ZarrUserWarning
20+ from zarr .errors import ChunkNotFoundError , ZarrUserWarning
2121from zarr .registry import register_pipeline
2222
2323if TYPE_CHECKING :
@@ -248,7 +248,9 @@ async def encode_partial_batch(
248248
249249 async def read_batch (
250250 self ,
251- batch_info : Iterable [tuple [ByteGetter , ArraySpec , SelectorTuple , SelectorTuple , bool ]],
251+ batch_info : Iterable [
252+ tuple [ByteGetter , ArraySpec , SelectorTuple , SelectorTuple , bool , str , tuple [int , ...]]
253+ ],
252254 out : NDBuffer ,
253255 drop_axes : tuple [int , ...] = (),
254256 ) -> None :
@@ -259,15 +261,17 @@ async def read_batch(
259261 for byte_getter , chunk_spec , chunk_selection , * _ in batch_info
260262 ]
261263 )
262- for chunk_array , (_ , chunk_spec , _ , out_selection , _ ) in zip (
264+ for chunk_array , (_ , chunk_spec , _ , out_selection , _ , chunk_key , chunk_coords ) in zip (
263265 chunk_array_batch , batch_info , strict = False
264266 ):
265267 if chunk_array is not None :
266268 out [out_selection ] = chunk_array
267269 elif chunk_spec .config .fill_missing_chunks :
268270 out [out_selection ] = fill_value_or_default (chunk_spec )
269271 else :
270- raise MissingChunkError
272+ raise ChunkNotFoundError (
273+ f"chunk '{ chunk_key } ' at grid position { chunk_coords } not found in store."
274+ )
271275 else :
272276 chunk_bytes_batch = await concurrent_map (
273277 [(byte_getter , array_spec .prototype ) for byte_getter , array_spec , * _ in batch_info ],
@@ -282,9 +286,15 @@ async def read_batch(
282286 )
283287 ],
284288 )
285- for chunk_array , (_ , chunk_spec , chunk_selection , out_selection , _ ) in zip (
286- chunk_array_batch , batch_info , strict = False
287- ):
289+ for chunk_array , (
290+ _ ,
291+ chunk_spec ,
292+ chunk_selection ,
293+ out_selection ,
294+ _ ,
295+ chunk_key ,
296+ chunk_coords ,
297+ ) in zip (chunk_array_batch , batch_info , strict = False ):
288298 if chunk_array is not None :
289299 tmp = chunk_array [chunk_selection ]
290300 if drop_axes != ():
@@ -293,7 +303,9 @@ async def read_batch(
293303 elif chunk_spec .config .fill_missing_chunks :
294304 out [out_selection ] = fill_value_or_default (chunk_spec )
295305 else :
296- raise MissingChunkError
306+ raise ChunkNotFoundError (
307+ f"chunk '{ chunk_key } ' at grid position { chunk_coords } not found in store"
308+ )
297309
298310 def _merge_chunk_array (
299311 self ,
@@ -470,7 +482,9 @@ async def encode(
470482
471483 async def read (
472484 self ,
473- batch_info : Iterable [tuple [ByteGetter , ArraySpec , SelectorTuple , SelectorTuple , bool ]],
485+ batch_info : Iterable [
486+ tuple [ByteGetter , ArraySpec , SelectorTuple , SelectorTuple , bool , str , tuple [int , ...]]
487+ ],
474488 out : NDBuffer ,
475489 drop_axes : tuple [int , ...] = (),
476490 ) -> None :
0 commit comments