Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mount "Computers" of Google Drive to Colaboratory

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!

like image 762
jfang Avatar asked Nov 08 '18 00:11

jfang


2 Answers

From Computers just right click the file and then click Add Shortcut 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. See image below.

Drive instructions

like image 162
Pavel Pricope Avatar answered Sep 22 '22 17:09

Pavel Pricope


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.

like image 36
acoles Avatar answered Sep 23 '22 17:09

acoles