Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I copy a file from colab to github repo directly? (It is possible to save the notebook in the Github repo)

How can I save a file generated by colab notebook directly to github repo? It can be assumed that the notebook was opened from the github repo and can be (the same notebook) saved to the same github repo.

like image 533
Itay Avatar asked Nov 18 '21 07:11

Itay


People also ask

How do I save colab files to GitHub?

After you have made changes to your notebook, you can commit and push them to the repository. To do so from within a Colab notebook, click File → Save a copy in GitHub . You will be prompted to add a commit message, and after you click OK , the notebook will be pushed to your repository.

How do I save my colab notebook?

Path to save in drive can be found easily by clicking files on left side, navigating to folder and right click to choose Copy path . This will save the image to folder named Delete in Google Drive.


Video Answer


1 Answers

Google Colaboratory's integrating with github tends to be lacking, however you can run bash commands from inside the notebook. These allow you to access and modify any data generated.

You'll need to generate a token on github to allow access to the repository you want to save data to. See here for how to create a personal access token.

Once you have that token, you run git commands from inside the notebook to clone the repository, add whatever files you need to, and then upload them. This post here provides an overview of how to do it in depth.

That being said, this approach is kind of cumbersome, and it might be preferable to configure colab to work over an SSH connection. Once you do that, you can mount a folder on the colab instance to a folder on your local machine using sshfs. This will allow you to access the colab as though it were any other folder on your machine, including opening it in your IDE, viewing files in a file browser, and cloning or updating git repositories. This goes more in depth on that.

These are the best options I was able to identify, and I hope one of them can be made to work for you.

like image 163
Alecto Irene Perez Avatar answered Oct 16 '22 20:10

Alecto Irene Perez