-
Notifications
You must be signed in to change notification settings - Fork 109
Set rm_files to be a synchronous method #503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
anjaliratnam-msft
wants to merge
7
commits into
fsspec:main
Choose a base branch
from
anjaliratnam-msft:rm_files_fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
78d8ba9
rm_files fix
anjaliratnam-msft b62bb25
added rm_file
anjaliratnam-msft c54a64a
updates
anjaliratnam-msft b8d09f3
updates
anjaliratnam-msft cab1c15
updates
anjaliratnam-msft 915295c
updates
anjaliratnam-msft ef84f97
updates
anjaliratnam-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2210,3 +2210,48 @@ def test_write_max_concurrency(storage, max_concurrency, blob_size, blocksize): | |
with fs.open(path, "rb") as f: | ||
assert f.read() == data | ||
fs.rm(container_name, recursive=True) | ||
|
||
|
||
def test_rm_file(storage): | ||
fs = AzureBlobFileSystem( | ||
account_name=storage.account_name, | ||
connection_string=CONN_STR, | ||
) | ||
path = "data/test_file.txt" | ||
with fs.open(path, "wb") as f: | ||
f.write(b"test content") | ||
|
||
assert fs.exists(path) | ||
fs.rm_file(path) | ||
with pytest.raises(FileNotFoundError): | ||
fs.ls(path) | ||
assert not fs.exists(path) | ||
assert path not in fs.dircache | ||
|
||
|
||
def test_rm_file_versioned_blob(storage, mocker): | ||
from azure.storage.blob.aio import ContainerClient | ||
|
||
fs = AzureBlobFileSystem( | ||
account_name=storage.account_name, | ||
connection_string=CONN_STR, | ||
version_aware=True, | ||
) | ||
mock_delete_blob = mocker.patch.object( | ||
ContainerClient, "delete_blob", return_value=None | ||
) | ||
path = f"data/test_file.txt?versionid={DEFAULT_VERSION_ID}" | ||
fs.rm_file(path) | ||
mock_delete_blob.assert_called_once_with( | ||
"test_file.txt", version_id=DEFAULT_VERSION_ID | ||
) | ||
|
||
|
||
def test_rm_file_does_not_exist(storage): | ||
fs = AzureBlobFileSystem( | ||
account_name=storage.account_name, | ||
connection_string=CONN_STR, | ||
) | ||
path = "data/non_existent_file.txt" | ||
with pytest.raises(FileNotFoundError): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's also add another separate test case where we try to call |
||
fs.rm_file(path) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Poking more through the adlfs codebase, I'm thinking we will also need to invalidate the
path
as well. While it does not seem like some of the other methods handle this (and arguably something we should circle back to addressing eventually), we can run into inconsistencies where the path can still reside in the dircache. For example, ifls()
is run on the file, it still shows up as present:We should make sure to add a test case for this as well.