Skip to content
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

Copy file to and from local #1694

Open
peterdudfield opened this issue Sep 27, 2024 · 3 comments
Open

Copy file to and from local #1694

peterdudfield opened this issue Sep 27, 2024 · 3 comments

Comments

@peterdudfield
Copy link

Ive perhaps missed something, and if so please do tell me,
p.s this is a great package, and I really like using it.

Im trying copy a file from

  1. remote to local
    or
  2. local to remote

It seems like I have to use two different methods
1

fs = fsspec.open(file2).fs
fs.put(file1, file2)

and

fs = fsspec.open(file1).fs
fs.get(file1, file2)

But it would be great just to have one functions that does this. It feels a bit like local is treated slightly different than other file system.

Appolgies if Ive miss understood something,

@martindurant
Copy link
Member

A more typical way to get the filesystem instance is

fs = fsspec.filesystem(protocol, ...)

or

fs = fsspec.url_to_fs(path, ...)

We also have fsspec.generic, where you can make a filesystem which can do get/put for multiple backend implementations. It would be reasonable to make these one-line commands for what you want.
The trouble is, most implementations take (many) arguments, and so you have the problem of mapping URLs not just to implementations but specific configured instances. That's not too easy to solve.

@martindurant
Copy link
Member

But yes, "local" is somewhat special. The generic FS I mentioned above allows fo copying (cp) between any backends, but of course the bytes must pass through the memory of the process making the call.

@peterdudfield
Copy link
Author

Thank you for the advice on getting fs, appreciate that.

Yea, I understand its complicated. Ill test out fsspec.generic and see if I can simplify the code.

Thank you once again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants