Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/3310.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add obstore implementation of delete_dir.
13 changes: 13 additions & 0 deletions src/zarr/storage/_obstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Store,
SuffixByteRequest,
)
from zarr.core.common import concurrent_map
from zarr.core.config import config

if TYPE_CHECKING:
Expand Down Expand Up @@ -196,6 +197,18 @@ async def delete(self, key: str) -> None:
with contextlib.suppress(FileNotFoundError):
await obs.delete_async(self.store, key)

async def delete_dir(self, prefix: str) -> None:
# docstring inherited
import obstore as obs

self._check_writable()
if prefix != "" and not prefix.endswith("/"):
prefix += "/"

metas = await obs.list(self.store, prefix).collect_async()
keys = [(m["path"],) for m in metas]
await concurrent_map(keys, self.delete, limit=config.get("async.concurrency"))

@property
def supports_partial_writes(self) -> bool:
# docstring inherited
Expand Down
Loading