Skip to content
Merged
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
11ac3d9
Implement asynchronous directory deletion in FsspecStore
carshadi Jan 6, 2025
32d8bc9
Merge branch 'zarr-developers:main' into feat-fsspecstore-bulk-delete
carshadi Jan 6, 2025
bfb4397
Use async batched _rm() for FsspecStore.delete_dir()
carshadi Jan 8, 2025
9812aec
Merge branch 'feat-fsspecstore-bulk-delete' of https://github.com/car…
carshadi Jan 8, 2025
f21f1c2
Suppress allowed exceptions instead of try-except-pass
carshadi Jan 8, 2025
220c28b
Adds note on possibly redundant condition in FsspecStore.delete_dir()
carshadi Jan 8, 2025
ece0f0e
Fix: unpack allowed arguments list
carshadi Jan 8, 2025
a280190
Merge branch 'main' into feat-fsspecstore-bulk-delete
jhamman Jan 10, 2025
bf78caf
Merge branch 'main' into feat-fsspecstore-bulk-delete
jhamman Jan 24, 2025
08dc4f9
Adds tests for FsspecStore.delete_dir
carshadi Jan 24, 2025
6ad9a0a
Update src/zarr/storage/_fsspec.py
carshadi Jan 29, 2025
89e1b5f
Remove supports_listing condition from FsspecStore.delete_dir
carshadi Jan 29, 2025
5e67566
use f-string for url formatting
carshadi Jan 29, 2025
a0214e4
assert `store.fs.asynchronous` instead of `store.fs.async_impl`
carshadi Jan 29, 2025
75ee3a5
Merge remote-tracking branch 'upstream/main' into feat-fsspecstore-bu…
carshadi Jan 29, 2025
aa4a7ff
updates release notes
carshadi Jan 29, 2025
8d44aed
Merge remote-tracking branch 'upstream/main' into feat-fsspecstore-bu…
carshadi Feb 14, 2025
96fb2f6
remove unused import
carshadi Feb 14, 2025
f1d90cc
Explicitly construct wrapped local filesystem for test
carshadi Feb 14, 2025
5c48759
Merge branch 'main' into feat-fsspecstore-bulk-delete
dcherian Feb 14, 2025
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
43 changes: 43 additions & 0 deletions src/zarr/storage/_fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,49 @@ async def delete(self, key: str) -> None:
except self.allowed_exceptions:
pass

async def delete_dir(self, prefix: str) -> None:
"""
Remove all keys and prefixes in the store that begin with a given prefix.
"""
if not self.supports_deletes:
raise NotImplementedError
if not self.supports_listing:
raise NotImplementedError
self._check_writable()

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

paths_to_delete = []
async for key in self.list_prefix(prefix):
paths_to_delete.append(_dereference_path(self.path, key))

if not paths_to_delete:
return

try:
import s3fs
except ImportError:
s3fs = None

# If s3fs is installed and our filesystem is S3FileSystem, do a bulk delete
if s3fs and isinstance(self.fs, s3fs.S3FileSystem):
try:
await self.fs._rm(paths_to_delete)
except FileNotFoundError:
pass
except self.allowed_exceptions:
pass
else:
# Otherwise, delete one by one
for path in paths_to_delete:
try:
await self.fs._rm(path)
except FileNotFoundError:
pass
except self.allowed_exceptions:
pass

async def exists(self, key: str) -> bool:
# docstring inherited
path = _dereference_path(self.path, key)
Expand Down
Loading