Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

accessing "Shared with me" with Colab

I want to get access to the files in the Google Drive's "Shared with me" directory.

In the Colab python notebook the following commands:

import os from google.colab import drive drive.mount('/content/drive') !ls "/content/drive/My Drive" 

work well for "My Drive" directory however

!ls "/content/drive/My Drive" 

fails with

FileNotFoundError: [Errno 2] No such file or directory:

I am aware of the fact that I can add the folder to my drive manually and proceed (as mentioned in here), but I would like to have direct access to the shared folders for lets say I might need to automate the work with files that are shared with me real time.

I am also aware that same/similar problem exist with other cloud platforms like "OneDrive".

The questions are:

  1. if there is no straightforward way of doing it, is there at least a workaround?
  2. do the people I share my code with get access to my drive too?
like image 451
Leon Rai Avatar asked Jan 24 '19 17:01

Leon Rai


People also ask

How do I open a shared Google colab file?

Using Colab. Colab notebooks are stored in Google Drive, or can be loaded from GitHub. Colab notebooks can be shared just as you would with Google Docs or Sheets. Simply click the Share button at the top right of any Colab notebook, or follow these Google Drive file sharing instructions.

How do I access shared with me on Google Drive?

Go to drive.google.com. On the left, click Shared with me. Select the files or folders to which you want to add a shortcut.

Can I access local files from Colab?

Since a Colab notebook is hosted on Google's cloud servers, there's no direct access to files on your local drive (unlike a notebook hosted on your machine) or any other environment by default. However, Colab provides various options to connect to almost any data source you can imagine.


2 Answers

Another work around is go to Google Drive, right click on the folder in question, and then click "Add shortcut to Drive". This will allow you to access the folder from your drive!

like image 164
Pranav Pillai Avatar answered Sep 19 '22 02:09

Pranav Pillai


RE: Is there a work-around --

Load your shared files in the web UI, right click on the directory of interest, and select 'Add to my Drive'. Then, the folder will appear in /content/drive/My Drive as you hope.

For context, Drive isn't like a normal filesystem: files and directories can have multiple parents, thereby appearing in both your file list and the original owners.

RE: Will other users have access to Drive files? --

No, the notebook is a distinct object in Drive with distinct Drive permissions.

like image 25
Bob Smith Avatar answered Sep 20 '22 02:09

Bob Smith