Skip to content

Commit ef136e9

Browse files
ziw-liud-v-b
andauthored
Add sharding to multiprocessing test (#3475)
* add sharding to multiprocessing test * Update tests/test_array.py --------- Co-authored-by: Davis Bennett <[email protected]>
1 parent b5e0793 commit ef136e9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tests/test_array.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,12 +1789,20 @@ def _index_array(arr: Array, index: Any) -> Any:
17891789
],
17901790
)
17911791
@pytest.mark.parametrize("store", ["local"], indirect=True)
1792-
def test_multiprocessing(store: Store, method: Literal["fork", "spawn", "forkserver"]) -> None:
1792+
@pytest.mark.parametrize("shards", [None, (20,)])
1793+
def test_multiprocessing(
1794+
store: Store, method: Literal["fork", "spawn", "forkserver"], shards: tuple[int, ...] | None
1795+
) -> None:
17931796
"""
17941797
Test that arrays can be pickled and indexed in child processes
17951798
"""
17961799
data = np.arange(100)
1797-
arr = zarr.create_array(store=store, data=data)
1800+
chunks: Literal["auto"] | tuple[int, ...]
1801+
if shards is None:
1802+
chunks = "auto"
1803+
else:
1804+
chunks = (1,)
1805+
arr = zarr.create_array(store=store, data=data, shards=shards, chunks=chunks)
17981806
ctx = mp.get_context(method)
17991807
with ctx.Pool() as pool:
18001808
results = pool.starmap(_index_array, [(arr, slice(len(data)))])

0 commit comments

Comments
 (0)