Repository navigation
fix(fsspec): don't silently skip get_file for file:// and Windows paths - #831
Open
andyhetianjun wants to merge 1 commit into
Open
andyhetianjun wants to merge 1 commit into
andyhetianjun wants to merge 1 commit into
Conversation
… paths
`_get_file` returned without writing anything when `lpath` had a URL
scheme. That includes `file://` URLs, and every Windows path, since
`urlparse("C:\\...")` reads the drive letter as a scheme.
Use fsspec's `split_protocol`, which ignores drive letters, strip a
`file://` prefix, and raise a `ValueError` for any other protocol.
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #830
_get_filereturned early, without writing anything or raising, wheneverurlparse(lpath)found a scheme. That meantget_file(rpath, "file:///tmp/out.txt")did nothing, and on Windows every normal path did nothing too, sinceurlparsereadsC:as the schemec.This PR uses fsspec's
split_protocolinstead. It doesn't treat a drive letter as a protocol, so Windows paths go through unchanged. Afile://prefix is stripped, and any other protocol (likes3://...) now raises aValueErrorinstead of returning silently. The directory check after it is the same as before.Tests: I added three tests to
tests/test_fsspec.pythat use the memory store, so they don't need MinIO:get_fileto afile://URL writes the bytesget_filetoC:\Users\me\out.txtpasses that path on to the local store's_pipe_file(mocked, since CI runs on Linux)get_filetos3://bucket/out.txtraisesValueErrorAll three fail on main and pass with this change. I don't have a Rust toolchain set up, so I tested this change to
fsspec.pyagainst the published 0.12.1 wheel, with fsspec 2026.2.0 and pytest 9.0.2 fromuv.lock. Docker isn't running on my machine, so the MinIO tests didn't run here. None of them callgetorget_file. The rest oftest_fsspec.pygave the same results with and without this change. The only failure,test_construct_local_store_fsync, fails on main too because the 0.12.1 wheel doesn't havefsyncyet.ruff check,ruff formatand pyright 1.1.406 are clean on the two files.I only have a Mac, so I couldn't try a real Windows path end to end. #763 may still cause problems for local paths on Windows after this point.
#818 changes the same
ifline in_get_file, so whichever one merges second will have a small conflict. I'm happy to rebase.