3838 NDBuffer ,
3939 default_buffer_prototype ,
4040)
41+ from zarr .core .buffer .cpu import buffer_prototype as cpu_buffer_prototype
4142from zarr .core .chunk_grids import RegularChunkGrid , _auto_partition , normalize_chunks
4243from zarr .core .chunk_key_encodings import (
4344 ChunkKeyEncoding ,
@@ -163,19 +164,20 @@ async def get_array_metadata(
163164) -> dict [str , JSON ]:
164165 if zarr_format == 2 :
165166 zarray_bytes , zattrs_bytes = await gather (
166- (store_path / ZARRAY_JSON ).get (), (store_path / ZATTRS_JSON ).get ()
167+ (store_path / ZARRAY_JSON ).get (prototype = cpu_buffer_prototype ),
168+ (store_path / ZATTRS_JSON ).get (prototype = cpu_buffer_prototype ),
167169 )
168170 if zarray_bytes is None :
169171 raise FileNotFoundError (store_path )
170172 elif zarr_format == 3 :
171- zarr_json_bytes = await (store_path / ZARR_JSON ).get ()
173+ zarr_json_bytes = await (store_path / ZARR_JSON ).get (prototype = cpu_buffer_prototype )
172174 if zarr_json_bytes is None :
173175 raise FileNotFoundError (store_path )
174176 elif zarr_format is None :
175177 zarr_json_bytes , zarray_bytes , zattrs_bytes = await gather (
176- (store_path / ZARR_JSON ).get (),
177- (store_path / ZARRAY_JSON ).get (),
178- (store_path / ZATTRS_JSON ).get (),
178+ (store_path / ZARR_JSON ).get (prototype = cpu_buffer_prototype ),
179+ (store_path / ZARRAY_JSON ).get (prototype = cpu_buffer_prototype ),
180+ (store_path / ZATTRS_JSON ).get (prototype = cpu_buffer_prototype ),
179181 )
180182 if zarr_json_bytes is not None and zarray_bytes is not None :
181183 # warn and favor v3
@@ -1348,7 +1350,7 @@ async def _save_metadata(self, metadata: ArrayMetadata, ensure_parents: bool = F
13481350 """
13491351 Asynchronously save the array metadata.
13501352 """
1351- to_save = metadata .to_buffer_dict (default_buffer_prototype () )
1353+ to_save = metadata .to_buffer_dict (cpu_buffer_prototype )
13521354 awaitables = [set_or_delete (self .store_path / key , value ) for key , value in to_save .items ()]
13531355
13541356 if ensure_parents :
@@ -1360,7 +1362,7 @@ async def _save_metadata(self, metadata: ArrayMetadata, ensure_parents: bool = F
13601362 [
13611363 (parent .store_path / key ).set_if_not_exists (value )
13621364 for key , value in parent .metadata .to_buffer_dict (
1363- default_buffer_prototype ()
1365+ cpu_buffer_prototype
13641366 ).items ()
13651367 ]
13661368 )
0 commit comments