Mount “Computers” of Google Drive to Colaboratory

痞子三分冷 提交于 2019-12-21 17:42:04

问题


I studied some ways of loading data to Colaboratory from the official notebook.

But it only connects the colab with Google Drive's "My Drive" folder by the command

drive.mount('/content/gdrive')

Picture for colab directory tree

However, I would like to access Google Drive's "Computers" folder in Colab. Is there some way to do it?

Picture for Google Drive web directory tree

Thanks!


回答1:


Here is a partial solution that may work for you:

By using the Files: update API call, you can add "root" as a parent to any folder inside the computer that you're syncing (set addParents="root"). This way a folder can live in both your Computers section and your My Drive, and should show up in Colaboratory.




回答2:


From Computers just do Add to Drive to the file you would like to open in Colab. This will create a shortcut of that file to Drive. Now when you modify the file there(gdrive) it will automatically be updated on Computers as well.




回答3:


In the web app of Google Drive, drag the folders of desire to your main drive. Requires you to remount drive in your colab notebook.




回答4:


Here is a hack that worked for me. You will need two Google accounts: let's call the one with which you're currently mounting to "Computers" from your local drive A, and the one in which you want to run the notebook B.

  1. Using account A, ensure that your files are correctly mounted and visible under "Computers" in your Drive's directory structure.

  2. Turn on link sharing for this directory.

  3. Basically, you now need to share this link with yourself. Log into account B and visit the link; doing so should land you in the "Shared with me" area of Drive, where you should see your directory.

  4. Drag and drop the directory onto the "My Drive" area in the filetree on the left. This will add the shared directory to the Drive of account B (i.e. no longer in a "Computers" directory, but now in a "My Drive" directory).

  5. In Colab using account B, mount your Drive as usual. You should now be able to access your files under "My Drive" of account B, shared with yourself via account A.

From what I can tell, sharing the directory is the only workaround that can actually move the whole directory from a "Computers" area to a "My Drive" one.




回答5:


I found a way works for me, the basic principle is to change the way you sync files.

From your expressions, I think your aim is to apply synced files from your local computer to Google Colaboratory. Though we can't mount 'Computers' to Colaboratory, we can mount 'My Drive'.

What I do is as follows:

  1. Create a folder in 'My Drive', for example as 'Gd test drive'.

  2. Sync 'Gd test drive' folder to local computer, shown as following figure:

    P.S. This figure refers to How Does Google Backup and Sync Work: A Comprehensive Guide for demonstration.

  3. Create files you want to sync with Google Drive, and they will be synced and accessed by Google Colaboratory.

  4. Mount your drive to Colaboratory, then you can get access to your target folders or files.

    from google.colab import drive
    drive.mount('/gdrive')
    


来源:https://stackoverflow.com/questions/53199781/mount-computers-of-google-drive-to-colaboratory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!