File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -444,6 +444,7 @@ def extract_zarr_variable_encoding(
444
444
safe_to_drop = {"source" , "original_shape" , "preferred_chunks" }
445
445
valid_encodings = {
446
446
"chunks" ,
447
+ "shards" ,
447
448
"compressor" , # TODO: delete when min zarr >=3
448
449
"compressors" ,
449
450
"filters" ,
@@ -825,6 +826,7 @@ def open_store_variable(self, name):
825
826
{
826
827
"compressors" : zarr_array .compressors ,
827
828
"filters" : zarr_array .filters ,
829
+ "shards" : zarr_array .shards ,
828
830
}
829
831
)
830
832
if self .zarr_group .metadata .zarr_format == 3 :
Original file line number Diff line number Diff line change @@ -2496,6 +2496,24 @@ def test_chunk_encoding(self) -> None:
2496
2496
with self .roundtrip (data ) as actual :
2497
2497
pass
2498
2498
2499
+ def test_shard_encoding (self ) -> None :
2500
+ # These datasets have no dask chunks. All chunking/sharding specified in
2501
+ # encoding
2502
+ if has_zarr_v3 and zarr .config .config ["default_zarr_format" ] == 3 :
2503
+ data = create_test_data ()
2504
+ chunks = (1 , 1 )
2505
+ shards = (5 , 5 )
2506
+ data ["var2" ].encoding .update ({"chunks" : chunks })
2507
+ data ["var2" ].encoding .update ({"shards" : shards })
2508
+ with self .roundtrip (data ) as actual :
2509
+ assert shards == actual ["var2" ].encoding ["shards" ]
2510
+
2511
+ # expect an error with shards not divisible by chunks
2512
+ data ["var2" ].encoding .update ({"chunks" : (2 , 2 )})
2513
+ with pytest .raises (ValueError ):
2514
+ with self .roundtrip (data ) as actual :
2515
+ pass
2516
+
2499
2517
@requires_dask
2500
2518
@pytest .mark .skipif (
2501
2519
ON_WINDOWS ,
You can’t perform that action at this time.
0 commit comments