Colaboratory and GitHub
Let me start with how to access notebook files. To view or edit the contents of your notebooks, you will first have to create a GitHub account. This is simple. You just have to go to your main account page at github.com, navigate to the Settings, enable “developers” and finally click on the “create your own repository” link. It will ask you for the GitHub API key (see here ), so go ahead and give it a try. Now you can view / edit your notebooks on the home page of GitHub.
- How to use GitHub with Colab
- My real life example with GitHub
- How to use Google Drive with Colab
This article will also provide an example using Google Drive. You just need to follow the steps outlined in the next section. This is what you should do after your initial setup. There will be an account called “Admin” in your Google Drive account. Just enter your Google Drive account username and password. It will show up as Google.com/Admin. This is how it looks like. (it’ll be different in your setup)
At this point, you can create new project or use already existing projects.
A Notebook from Github
After you have established your project in Google Drive, let us go through the process of adding a notebook from Github.
How to create a Google Drive notebook with Github
(download the.zip or copy all of.pst and.pst from this folder to your notebook root)
– Create a new folder in your notebook. I called it “Datasets” (in my example “Datasets/Rdatasets”). – Upload your.pst to your Github directory, containing some.csv files and/or some other types of files. (DO NOT upload this to your project!) – To check the contents of your.pst file, go to Google Drive > Manage repositories > Add repositories > Insert repo. – Save the.pst file, name it with a name of your choice. – Launch Colab. Select File > Open > Add (select type “Notebook”, choose a “.pst” file to open) Select “Datasets” and save the notebook. Make sure the Labels tab is selected in Colab. You may see a toolbar with a whole bunch of options (see screen shot here ). Right after you enter the “Datasets” folder in Colab, click the toolbar button next to the “Labels” tab. This will open the context menu of the first Dataset in the list. The list displays the repositories that you have applied notebooks to, a link to the corresponding GitHub repo and finally the generated repo with the code you specify (see screenshot below). Labels tab The first row will display the labels from your “Datasets” folder that you have used in the “Labels” tab in Colab. In my example, my “Datasets/Rdatasets” folder is displayed. You can rename the folder, but I would advise against it. By default, the folder is named “Rdatasets”, however, if you rename it, you will have to overwrite it with the newly generated one. More about Labels in Colab can be found here. Below, the second row displays the labels from the repository in the first row of the list. It displays a link to
It comes pre-configured and ready to go with GitHub for your GitHub repository.
Only difference from last solution is we have to enable Google Docs
This post should guide you to the most usefull way of using Colab. If you have any questions, comments, suggestions etc, please leave a comment.
After following the steps in this article, we will create a Colab repository. In order to create a repository, we must have a public GitHub or Gist repo URL.
Creating a public GitHub repository Let’s create a URL for our GitHub repo.
From my host-name : gitserver where I have read gitserver for my server [you can find it by just checking your public IP address]. (google it)
Insert the following text.
You have entered your Public GitHub repository URL.
This URL will create a repository on your computer (requires http package on Linux) and is not usable from outside the internet. We cannot access our Git repo ( git -c ) from outside of this URL, so we have to ask another way. It will be useful to use some service like gitweb or gitk to get the repository URL from anywhere you are connected to internet.
Create a read only branch
Let’s create a READ-ONLY branch and install the Google Project Colab client.
On your computer: For your Gist-Id : gitserver – a directory where you have downloaded the Google Project Colab client.
For your Source-Id : gitserver – a directory where you have copied the READ-ONLY repo.
On your host-name: https://github.com/olegerohme/gitserver
Open the file Add .
Choose the branch you want to create.
Specify the branch name, new message of the commit, and the message of the commit message in one line (one line per commit). This command generates a name like example1.git and is used for creating branches from our repo. This might not be optimal for creating branches of new repo in a working folder. It also creates an invalid message of the commit for the normal git commands. Go to the repository to add the remote. On your computer: cd to the directory where you created a READ-ONLY branch and type: git remote add origin git@github.com:olegerohme/gitserver.git Go to the repository on GitHub to add the remote. In order to do so, use a service like gitweb. For your Gist-Id : gitserver – a directory where you have downloaded the Google Project Colab client. For your Source-Id : gitserver – a directory where you have copied the READ-ONLY repo. Go to the repository on GitHub to add the remote. On your computer: cd to the directory where you created a READ-ONLY branch and type: git remote add origin git@github.com:olegerohme/gitserver.git Tip: Make sure to add the READ-ONLY to your repo’s remote in order for the.gitignore to be filled in.
Adding a remote of another project¶ Once you have the READ-ONLY branch populated with commits, you need to be