File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from __future__ import annotations
22
33import os
4+ import shutil
45import threading
56import time
67import zipfile
@@ -288,3 +289,16 @@ async def list_dir(self, prefix: str) -> AsyncIterator[str]:
288289 if k not in seen :
289290 seen .add (k )
290291 yield k
292+
293+ async def move (self , path : Path | str ) -> None :
294+ # docstring inherited
295+
296+ if isinstance (path , str ):
297+ path = Path (path )
298+ if not isinstance (path , Path ):
299+ raise TypeError (
300+ f"'path' must be a string or Path instance. Got an instance of { type (path )} instead."
301+ )
302+ os .makedirs (path , exist_ok = True )
303+ shutil .move (self .path , path )
304+ self .path = path
Original file line number Diff line number Diff line change 1010import pytest
1111
1212import zarr
13+ from zarr import create_array
1314from zarr .core .buffer import Buffer , cpu , default_buffer_prototype
1415from zarr .storage import ZipStore
1516from zarr .testing .store import StoreTests
@@ -135,3 +136,17 @@ def test_externally_zipped_store(self, tmp_path: Path) -> None:
135136 zipped = zarr .open_group (ZipStore (zip_path , mode = "r" ), mode = "r" )
136137 assert list (zipped .keys ()) == list (root .keys ())
137138 assert list (zipped ["foo" ].keys ()) == list (root ["foo" ].keys ())
139+
140+ async def test_move (self , tmp_path : Path ):
141+ origin = tmp_path / "origin"
142+ destination = tmp_path / "destintion"
143+
144+ store = await ZipStore .open (path = origin , mode = "w" )
145+ array = create_array (store , data = np .arange (10 ))
146+
147+ await store .move (destination )
148+
149+ assert store .path == destination
150+ assert destination .exists ()
151+ assert not origin .exists ()
152+ assert np .array_equal (array [...], np .arange (10 ))
You can’t perform that action at this time.
0 commit comments