Google Colab API - google-drive-api

Is there a Google Colab API? I'm looking to accomplish things like:
Create users
Create notebooks
Share notebooks with users
Retrieve the contents of a notebook

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 very limited documentation.
Official Documentation (very limited)
Google Colab: Official FAQ
The Google Colab: Official Feature Demo exemplifies most features. Use it to learn many of its capabilities.
The API in code
Beyond those resources, your best bet would be going to the Official Github Repository. Here are some highlights from the 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 Notes
The FAQ explains many important 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...
drive.mount asks for your permission again
you have to re-install all packages
any newly created files are all gone (unless you put em in a drive-mounted folder)

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

Related

Google Cloud Project does not exist (but should)

Before I start, I'm having the same issue as this question and this question. Unfortunately, neither of those solutions is working for me.
I have an add-on in the G Suite Marketplace. There are two separate entries, one for a Docs version and one for a Slides version. Now that the Chrome web store is being phased out for add-ons, I want to combine them into the same listing (afaik, that wasn't possible in the web store, only G Suite Marketplace).
Because of this, I now need to associate the Apps Script projects for both the Docs and Slides version with the same Cloud project. I'm hoping to migrate both to the Docs version because that has more users so hopefully fewer people will be impacted by the move.
I've taken the following steps:
Duplicate the Slides Apps Script project (to avoid messing with the original Marketplace listing until everything is set)
Go into the Cloud Platform settings for the new Slides App Script project
Enter the Cloud Platform project number for the Docs add-on
When I do this, I get an error that says "Project does not exist or you need edit access to it."
The weird thing is that if I try these steps to switch both projects to the Slides version in the Marketplace, it works. Because of this, I'm assuming there's some issue with the Cloud Platform project for the Docs version, but I can't seem to figure out what it is. Does anyone have any tips for common settings that could cause this error?
I was having the same problem and found out that it has something to do with the Shared Drive you have for a team.
Using the answer found by Ian: Google Apps Script cannot convert from GAS managed to specific Cloud Project
If the project is in a Shared Google Drive, like a team drive, you are no longer the owner (even if it says you are).
I couldn't create a new project in a shared drive and convert it to a Cloud Managed Project.
The only way I could do it was to create a new project on my account, in My Drive, and convert that to a Cloud Managed Project, THEN move it to the shared drive. (Once it is in a shared drive, you can't MOVE it back out.) However, if it is a Cloud Managed Project, you can add more scopes to the project after it is in the shared drive. - Once this new project is setup, then copy over your code for your old copy, and point all links to the new one.

Cloud Storage Download Appears to Be Malicious

I uploaded a utility in the last few days to google cloud storage.
It's a zip file containing two executables and a readme file.
I tested the download and it worked fine. I then looked into how I could see the download stats and yesterday I enabled logging.
I posted the link to a mailing list this afternoon and clicked it to verify that I had the right link and the download in chrome reports "xxx.zip appears to be malicious".
This did not happen prior to when I enabled logging, but I don't know for sure that is what caused it.
I am using a CNAME alias for the download, and I am a paying google apps customer.
The executables are not malicious in any way. They are simple utilities for doing replacements in text files. They do not access the network at all.
My question is "Why is my zip file being reported as malicious?" and is there any way to remedy this situation?
I looked around for a solution to this problem and I found the following advice:
1) Sign your EXEs. As it turns out, this advice is incorrect. While it has worked for some people, there are people who report that even signed executables are reported as malicious downloads.
2) Use SSL. SSL access is not available for google cloud storage unless you use the commondatastorage.googleapis.com or sandbox.google.com URLs. While this does might work, it doesn't resolve my problem.
3) Use the commondatastorage.googleapis.com URL. This works. The same file using the commondatastorage.googleapis.com url rather than my custom CNAME record does not report that it "appears malicious".
4) Register your site with Google Webmaster Tools. Getting around Chrome's Malicious File Warning According to this stackoverflow entry, the solution is to sign up for Google Webmaster Tools and add your site.
I have tried this one, but it has not made a change just yet. Because this is google cloud storage and not a main site, I added an index.html page, a 404 page, and ran the gsutil commands to enable web configuration within google cloud storage. I added the site to Webmaster Tools and additionally added it to Google Analytics.
I'll give solution 4 a few days to see if it pans out.
It seems like this is more of an issue with Google Chrome and not necessarily Google Cloud Storage. Chrome's methods for identifying malicious files are less than desirable right now.

Accessing Google Drive SDK from Perl

I have couple of Perl scripts that uploads / reads files from Google drive. Is it possible to access Google drive with Perl Api, or I need to switch to python or some scripting languages that Google supports.
We have a REST API. You can use any language to implement your own client, you don't have to use one of the client libraries we support.
An overview of the resources are here: https://developers.google.com/drive/v2/reference
Auth is explained on https://developers.google.com/accounts/docs/OAuth2#webserver
File upload is explained on https://developers.google.com/drive/manage-uploads
I just found a nice cpan module for talking to Google drive. So it might be as useful to you as it will be to me, because I just started playing with it. The only thing that is weird about it is that it needs to run install script to create the initial credentials on your machine.
http://search.cpan.org/~mschilli/Net-Google-Drive-Simple-0.03/lib/Net/Google/Drive/Simple.pm#SYNOPSIS

Incorporate Google Drive solution in existing Android app project?

I have an existing Android app project which has been already published on the Google Play, and now I would like to incorporate in my app the possibility to use the Google Drive possibilities in order to download *.jpg files directly to the sd card when the app is opened or load for the first time. Like this I liberate the internal memories of the phones where this app is installed (All the images are stored in the resources of the app actually which is >~ 20MB). I have read a lot of forums concerning the Google Drive SDK or API subjects and I can say that I'm a little bit lost on the manner to manage it for my present app. Some ideas or suggestions would be very very very appreciated.
Thank you very much).
Please see this question for the basics on how to integrate your Android app with Google Drive SDK: Access to Google Drive from self implemented Android application
In it, I reference a good Google+ tutorial on how to get started, and it's easy enough to take the concepts and apply them to an existing app. (That's how I did it too.) Before you get started, sign up for the Google APIs (https://code.google.com/apis/console/), get into the API Console, and turn on both the Google Drive API and Drive SDK. This'll make coding go a lot smoother. Let me know if you have any problems.
One addendum for your specific case relating to *.jpg files is you could set a MIME type for fetching strictly the pictures. It'd go something like this:
request = service.files().list(); // .setQ("mimeType=\"text/plain\"");
Unfortunately setQ is commented out because it would fail to return any results when I used it. However, you may have better luck with the image/jpeg MIME type.

How to upload a file from Salesforce to Google drive?

Is it possible to upload a file, pdf or word, from a web application made in Salesforce to a Google drive?
I have downloaded the integration toolkit for Google. I can create the file but I am not able to upload the file.
How should I do this?
You have to integrate your web application with the Drive SDK as described in the docs: https://developers.google.com/drive/apps_overview
I don't know the Salesforce integration toolkit for Google, but there are complete Drive SDK sample apps in different programming languages at https://developers.google.com/drive/examples/index
You can definitely do that. In fact I had done an implementation on the Force.com platform where users could actually upload files to their bucket of space on the Google Drive.
I have started a blog (integration-of-google-drive-into-force-com) just a few days ago and through which I am planning to pass on all my experiments that I would do the Force.com platform to every one around.
I have given a detailed description of the same on my blog. You can visit the same and do approach me for doubts and clarifications.