Repository navigation
Accept a list of paths in WebHDFS.rm - #2560
Conversation
WebHDFS.rm passed its argument straight to the request, so a list of paths raised TypeError before anything was sent. Delete each path in turn, as ArrowFSWrapper.rm does.
|
One interaction with #2502 now that it has merged: the list loop can raise on a path it already removed, before reaching the rest of the list. I applied only the list hunk from Could we add a duplicate-path test and a recursive parent-plus-child test after rebasing? Deduplicating the list and handling children before listed parents would avoid creating these missing-path errors without weakening #2502's scalar check. |
When rm gets a list, drop duplicate paths and delete children before their listed parents. A path removed earlier in the list is no longer reported as missing, so the remaining paths are still deleted.
80195d7 to
95f9fb6
Compare
|
Thanks for adding the duplicate and parent-before-child regressions. I reran the original loopback HTTP fixture against the exact |
Fixes #2559
WebHDFS.rmoverrides the basermand passed its argument straight to_call, so calling it with a list of paths raisedTypeErrorbefore any request was sent. The base API documentspathas "str or list of str".WebHDFS.rmnow handles a list by calling itself once per path, the same wayArrowFSWrapper.rmdoes. Before the loop it removes duplicate paths (after stripping the protocol and any trailing slash) and sorts the rest deepest first, so a listed child is deleted before its parent. Without this, a duplicate, or a child listed after its parent was removed recursively, was requested again after it was gone, and #2502's missing-path check raised and stopped the rest of the list. A path that is really missing still raises. Each element is a string, so the recursion stops after one level and does not go throughrm_file. Single-path calls are unchanged. The changelog has a new entry under Dev > Fixes.Tested:
uv run --no-sync python -m pytest fsspec/implementations/tests/test_webhdfs.py -v, passes.test_rm_list_of_paths,test_rm_list_duplicate_pathsandtest_rm_list_parent_and_childpass. On master all three fail, because a list raisesTypeErrorthere. The last two use the two cases from the review.pre-commit run --all-fileswas not run.