Skip to content

openafox/gitcommitpush

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gitcommitpush

gitcommitpush is a jupyter notebook extension enabling users push ipython notebooks to a git repo (tested for github and gitlab but should work for others). The git button gets displayed in the notebook toolbar. After saving any notebook the user can push notebook to pre-specified git repository. There are few environment variables that must be exported. Currently this extension supports commits to a single github repo defined in environment variable but in the long run need help to modify this extension allowing user to select his repo and branch.

Installation

You can currently install this directly from git:

pip install git+https://github.com/openafox/gitcommitpush.git

Or clone from git(repo) and install in develop mode to allow you to make edits (ideally in a virtualenv so sudo or --user in not needed):

git clone https://github.com/openafox/gitcommitpush.git
cd gitcommitpush/
python setup.py develop


jupyter serverextension enable --py gitcommitpush
jupyter nbextension install --py gitcommitpush

To enable this extension for all notebooks:

jupyter nbextension enable --py gitcommitpush

To enable in virtualenv append --sys-prefix to 3 commands above see: https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/install.html#install-javascript-and-css-files

Steps

  • Install package using above commands
  • Create Git repo where notebooks will be pushed if not already exists and clone it in your GIT_PARENT_DIR
  • Clone this repo as well in your GIT_PARENT_DIR directory
  • Replace the values in env.sh present in this repo itself
  • Run the command - source ~/gitcommitpush/env.sh
  • Configure ssh key (present in ~/.ssh/id_rsa.pub or specified location) in git(repo) account
  • Run jupyter notebook from within your repo directory

Suggestion - nbdime

nbdime allows you to only track code changes and not outputs. It also gives a nice visual diff

https://nbdime.readthedocs.io/en/latest/

Example installation of nbdime:

pip install nbdime
jupyter serverextension enable --py nbdime --sys-prefix
jupyter nbextension install --py nbdime --sys-prefix
jupyter nbextension enable --py nbdime --sys-prefix
nbdime config-git --enable

Example git configuration

export GIT_PARENT_DIR=~
export GIT_REPO_NAME=gitjupyter
export GIT_BRANCH_NAME=master
export GIT_USER=sat28
export GIT_EMAIL=anand.shaleen@gmail.com
export GITHUB_ACCESS_TOKEN=#access-token from git(repo) developer settings
export GIT_USER_UPSTREAM=sat28

Screenshots

Extension

Commit Message

Success Message

Credits

Thanks to https://github.com/Lab41/sunny-side-up for laying the foundation of this extension.

Thanks to https://github.com/justvarshney for support.

This is a fork of https://github.com/sat28/githubcommit

Thanks for getting this started!!

About

A jupyter notebook extension enabling users push ipython notebooks to a git repo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 55.8%
  • JavaScript 33.8%
  • Shell 10.4%