fix(asyn): support sync style implementation in async _rm_file #1951
+44
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix AsyncFileSystem._rm_file() to support sync-style implementations
Summary
Fixes architectural inconsistency between sync and async file deletion APIs that prevents
rm_file()from working on async filesystems that implement_rm()instead of_rm_file().Problem
The async and sync APIs have inverted delegation patterns:
Sync (AbstractFileSystem):
Async (AsyncFileSystem):
This breaks external async filesystems (like
adlfs.AzureBlobFileSystemwhere this issue was encoutered) that follow the sync pattern and implement_rm()but not_rm_file():fs.rm()works (calls the overridden_rm())fs.rm_file()fails withNotImplementedError(calls_rm_file()which isn't implemented)Root Cause
Proposal
Make
_rm_file()detect if subclass implements_rm()and delegate to it:Changes
Modified Files
fsspec/asyn.py
_rm_file()fsspec/tests/test_async.py
test_rm_file_with_rm_implementation(): Tests sync-style pattern (implements_rm())test_rm_file_with_rm_file_implementation(): Tests async-style pattern (implements_rm_file())test_rm_file_without_implementation(): Tests error handlingOpen to all feedback and happy to iterate !