9

In Google CoLab on the left is a pane that can be opened that shows Table of Contents, Code snippets, and Files. In the Files pane there is an upload button, I can upload a notebook file to this Files area. But once the notebook file is uploaded, there is no option to run it as a notebook. The menu option File->OpenNotebook doesn't show the CoLab /content/ files as an option to start a notebook. Is there a way to do this? Or can it be added in future releases?

The reason for this request is I'd like to git-clone a repo with multiple notebook files into the /content (or Files) area of CoLab. And then be able to easily switch between the notebooks, much like the native Jupyter notebook interface that shows a directory with potentially multiple notebooks that can be started.

I've tried right-clicking on the notebook file in Files but there is no option to start the notebook. I've tried using File->Open_notebook... the Files files aren't shown as an option in any of the tabs.

The desired results is that I can start .ipynb files (i.e. Jupyter notebooks) directly from the 'Files' or /content/ section of Google CoLab.

Carlos Cavero
  • 3,011
  • 5
  • 21
  • 41
Grant Wallace
  • 91
  • 1
  • 3

2 Answers2

5

You can run other notebooks in your current notebook like this:

# if the file was on the google drive
%run /content/gdrive/My\ Drive/Colab\ Notebooks/DenseVideoArchitecture.ipynb

# simply replace the path in your case
%run /content/DenseVideoArchitecture.ipynb

But what you are asking is to switch between different notebooks in the same environment which might not be possible in collab.

jkdev
  • 11,360
  • 15
  • 54
  • 77
Vasu Bansal
  • 451
  • 5
  • 7
2

I couldn't understand what you actually need, but I hope below code help you:

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

!cd content/gdrive/My Drive/Colab Notebooks

You should mount your google drive and now you have access to drive as a local drive. In this code, at first two lines, I mount gdrive and then I redirect to some place in google drive for example "Colab Notebooks" and you can run everything you want.

  • 1
    No, this is not what I mean. I'm not trying to open a notebook from my google drive, I'm trying to open a notebook within the CoLab filesystem itself, one that I have placed in the CoLab filesystem by git-cloning it there. – Grant Wallace Apr 25 '19 at 15:39
  • I think you should convert that file and then run it. maybe this link helps you: https://stackoverflow.com/questions/35545402/how-to-run-an-ipynb-jupyter-notebook-from-terminal . Also, you can clone it to gdrive and use it because the files in colab file are temporary and after restart runtime, they will be cleared. – Mohammad Javad Apr 25 '19 at 18:26