Skip to content

Commit bd43fe5

Browse files
authored
Fix copy_store to work in case of no chunks (#94)
1 parent 9119c12 commit bd43fe5

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

tests/test_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@ def test_split_metadata_and_data_keys_puts_metadata_before_chunks():
122122
assert data_keys == ["sample/c/1", "sample/c/0"]
123123

124124

125+
def test_copy_store_async_no_chunks():
126+
keys = ["sample/zarr.json", "zarr.json"]
127+
data = {key: key.encode() for key in keys}
128+
metadata_keys, _ = split_metadata_and_data_keys(keys)
129+
source = FakeSourceStore(data)
130+
dest = FakeDestStore(metadata_keys)
131+
132+
asyncio.run(copy_store_async(source, dest, io_concurrency=2))
133+
134+
assert dest.values == data
135+
136+
125137
def test_copy_store_async_uses_bounded_concurrency_and_metadata_barrier():
126138
keys = ["sample/c/0", "sample/zarr.json", "zarr.json", "sample/c/1", "sample/c/2"]
127139
data = {key: key.encode() for key in keys}

vczstore/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ async def _copy_one_key(key):
9090
for key in metadata_keys:
9191
await _copy_one_key(key)
9292

93-
await stream.map(
94-
stream.iterate(data_keys), _copy_one_key, task_limit=io_concurrency
95-
)
93+
if len(data_keys) > 0:
94+
await stream.map(
95+
stream.iterate(data_keys), _copy_one_key, task_limit=io_concurrency
96+
)
9697

9798

9899
def copy_store(source, dest, *, array_keys=None, io_concurrency=None):

0 commit comments

Comments
 (0)