PyDrive2
PyDrive2 copied to clipboard
Regsister fsspec interface with fsspec
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 can you show how / where is it done usually?
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.
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!
"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).
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