PyDrive2 icon indicating copy to clipboard operation
PyDrive2 copied to clipboard

Regsister fsspec interface with fsspec

Open martindurant opened this issue 1 year ago • 5 comments

The following stackoverflow question brought to my attention that, although this repo has an fsspec-compatible class, it is not registered with fsspec, so calls like fsspec.open("gdrive://...") don't work. Even importing the library does not seem to do the registration. (They DO work with the older gdrivefs.)

We should figure out what the appropriate protocol to use is and make sure that users have as smooth a path as possible to loading data off gdrive via fsspec.

martindurant avatar Jul 15 '24 13:07 martindurant

@martindurant can you show how / where is it done usually?

shcheklein avatar Jul 15 '24 15:07 shcheklein

https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.registry.register_implementation is probably what you want. If you call this on import of pydrive2.fs , then future calls ton fsspec.open() will know about it.

martindurant avatar Jul 15 '24 15:07 martindurant

For sshfs it's done automatically during package installation somehow: https://pypi.org/project/sshfs

And then users can use sshfs:// protocol for any fsspec-supporting code, without modifications

It would be great to have it for PyDrive2 as well!

vadimkantorov avatar May 18 '25 07:05 vadimkantorov

"gdrive:" is currently registered to gdrivefs here. Projects can register themselves by declaring entrypoints in the package metadata, or simply calling register_implementation on import (mentioned above).

martindurant avatar May 20 '25 13:05 martindurant

Could you please advise how to then form the gdrive:// link, given the file id? Or otherwise, are there anywhere complete examples of accessing files via gdrive://?

e.g. for anonymous-accessible files #https://drive.google.com/file/d/1I_bokg0Fejy7dVxNkZcJD4gCagawLIVY/view?usp=drive_link (txt) (or google doc https://docs.google.com/document/d/1WPDqkck6mYRh7pk4DoZP1zYuA-GARWOILg_4OosfDnQ/edit?usp=drive_link)

Or otherwise for non-anonymous files: is it possible to somehow embed the token directly in the gdrive:// url or pass the auth token in an environment variable? I am imagining getting the token on a machine with web-browser, and then pasting it into env variable on my remote ssh server for downloading some data files from Google Drive

vadimkantorov avatar May 20 '25 14:05 vadimkantorov