filesystem_spec icon indicating copy to clipboard operation
filesystem_spec copied to clipboard

Copy file to and from local

Open peterdudfield opened this issue 1 year ago • 3 comments

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,

peterdudfield avatar Sep 27 '24 12:09 peterdudfield

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 avatar Sep 27 '24 18:09 martindurant

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.

martindurant avatar Sep 27 '24 18:09 martindurant

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

peterdudfield avatar Sep 28 '24 08:09 peterdudfield