fsspec / fsspec/filesystem_spec

Copying files between filesystems via GenericFileSystem broken for filesystems requiring init parameters

Open
#1,167 11 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.4k
Forks
490
Avg merge
2d 3h
Merged PRs (30d)
38

Description

In our project, we use the GenericFileSystem's _cp_file function to (asynchronously) copy files from a remote SSH filesystem to our local filesystem (as suggested in this comment).

Before the release of 2023.1.0, this function accepted the parameters fs and fs2, which could be used to pass in existing filesystem instances between which the copy operation should take place. Since 2023.1.0 however, these parameters have been removed (silently and without reference in the changelog, though perhaps the 'experimental' note in the docs means changes won't get a notice?).

With the removal of these parameters, this function now only uses filesystem instances as resolved by the _resolve_fs function based on the url parameter. But, since the resolve function returns the result of a call to registry.filesystem() with only the inferred protocol as parameter (and no **storage_options), this fundamentally breaks for filesystems that require some parameter for their __init__ function, like the SFTPFileSystem (the default implementation for the SSH protocol, and which requires a host parameter).

This issue can easily be reproduced by calling the _cp_file function on a GenericFileSystem where one of the url parameters starts with "ssh://" as protocol, or any other protocol whose FileSystem implementation requires additional parameters.

Of course, if there is another workflow to get the _cp_file function working for pre-defined filesystems that is the 'intended' way, I would very much like to hear it and this issue should be closed.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in fsspec/generic.py at GenericFileSystem._cp_file and trace its calls to _resolve_fs, then inspect registry.filesystem in fsspec/registry.py. Reproduce the failure with an ssh:// URL and a filesystem requiring initialization parameters. Done means copying works for such filesystems while preserving the supported workflow for predefined filesystem instances, with the intended behavior documented or covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.