Google 上校 API

Google Colab API

是否有 Google Colab API?我希望完成类似的事情:

  1. 创建用户
  2. 创建笔记本
  3. 与用户共享笔记本
  4. 检索笔记本的内容

Google Colab 笔记本就像 Google 云端硬盘中的普通文件。

因此,您可以使用云端硬盘 API 像管理任何云端硬盘文件一样管理它们。

例如,您可以使用 Drive REST API 共享笔记本,如此处所述

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

正如其他答案中所指出的,Colab 笔记本是您 Google 驱动器上的文件。因此,可以通过 Google Drive API (from what I understand you can use the webContentLink 下载它们来共享它们或检索它们的内容。

但是,您的第一个问题是:

Google Colab API 在哪里?

对于从 Google 来到这里试图找到官方 Google Colab API 的任何人(因为它是目前谷歌搜索的最佳结果之一),这里是答案:

[截至 2020 年夏季] 由于这只是一个研究项目,因此没有官方 API 文档,因此某些信息可能很难获得。

你最好的选择是去 Official Github Repository:

代码中的API

更多文档 + 注释

常见问题解答解释了一些内部机制。亮点包括:

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

方便!

我衷心推荐查看 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)

虚拟机

常见问题解答还提到...

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.

这就是为什么您可以执行各种常见的系统调用(例如 !pip installopen 等)并且它正常工作的原因。

然而这也是为什么当你第二天回来时...

  1. drive.mount再次请求您的许可
  2. 您必须重新安装所有软件包
  3. 任何新创建的文件都消失了(除非你把它们放在驱动器安装的文件夹中)