Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Colab API

Tags:

Is there a Google Colab API? I'm looking to accomplish things like:

  1. Create users
  2. Create notebooks
  3. Share notebooks with users
  4. Retrieve the contents of a notebook
like image 715
Will Avatar asked May 30 '18 03:05

Will


People also ask

Does Google colab have API?

Google Colab Notebooks are just like a normal file in Google Drive. So, you can use Drive API to manage them just like any Drive files.

Is Google colab same as Python?

The Basics. Colaboratory, or “Colab” for short, is a product from Google Research. Colab allows anybody to write and execute arbitrary python code through the browser, and is especially well suited to machine learning, data analysis and education.

Is Google colab like Jupyter?

Google Colaboratory is a freemium tool offered by Google Research that allows users to write and execute Python code in their web browsers. Colab is actually based on the Jupyter open source, and essentially allows you to create and share computation files without having to download or install anything.


2 Answers

As pointed out in the other answer, Colab Notebooks are files on your Google Drive. Hence, sharing them or retrieving their contents can be done via the Google Drive API (from what I understand you can use the webContentLink to download it).

However, your first question is:

Where is the Google Colab API?

For anyone coming here from Google trying to find the official Google Colab API (because it's one of the top results when googling for now), here is the answer:

[As of summer 2020] Since this is merely a research project, there is no official API documentation and thus certain information might be hard to come by.

Your best bet would be going to the Official Github Repository:

The API in code

  • Github: google.colab
  • Github: google.colab.drive
  • Github: google.colab.drive.mount (used in quite a few snippets)
  • Github: google.colab.files (provides download and upload utilities)
  • Github: google.colab.snippets (add snippets to the snippets list programmatically; FYI: you can find all snippets by going to Insert -> Snippets)
  • Github: all packages

More Documentation + Notes

  • Google Colab: Official FAQ
  • Google Colab: Official Feature Demo

The FAQ explains some of the internal mechanics. Highlights include:

It’s a Jupyter notebook environment that requires no setup to use.

Convinient!

I heartly recommend checking out the Official Feature Demo; it's how I found out that it even supports LaTeX and MathJax! (but then again that might not come as news to someone with experience in Jupyter) 😄

Virtual Machine

The FAQ also mentions...

Code is executed in a virtual machine dedicated to your account. Virtual machines are recycled when idle for a while, and have a maximum lifetime enforced by the system.

That is why you can execute all kinds of the usual system calls (e.g. !pip install, open etc.) and it just works.

However that is also why when you come back the next day...

  1. drive.mount asks for your permission again
  2. you have to re-install all packages
  3. any newly created files are all gone (unless you put em in a drive-mounted folder)
like image 97
Domi Avatar answered Sep 22 '22 01:09

Domi


Google Colab Notebooks are just like a normal file in Google Drive.

So, you can use Drive API to manage them just like any Drive files.

For example, you can share notebooks with Drive REST API as documented here

https://developers.google.com/drive/api/v3/manage-sharing

like image 35
korakot Avatar answered Sep 19 '22 01:09

korakot