Package: create-jupyter-git
Create Jupyter GitA CLI command that generates a fresh Git repository with files and configs to optimize version control for Jupyter NotebooksDescriptionA common use of Jupyter Notebooks is for learning, taking notes, and having code examples that you can modify and run later. Other commons uses include proving out data analysis or machine learning which generates a lot of output in the form of images and data. In both of these scenarios, the output changes frequently and it not as important as the notebook configuration. The output can easily be regenerated for many use cases.The output generated by notebooks is a great candidate for to be ignored in aGitrepoitory so commits are minimal and point to meaningful code and not data that is derived from that code.There are a number of methods one can take to version control your Jupyter Notebooks and ignore the output.One of the best (documented here) is to utilize aGitfilter to target*.ipynbfiles and strip out theoutputfield in the json before it gets staged.This approach requires a few steps that you may not be interested in or may want to have to deal with when setting up a new repo for Jupyter Notebooks so this CLI command can be used to create and initialize aGitrepository with configs already in place. Simply startup your Jupyter Notebooks and commit when you hit a meaningful checkpoint.InstallationInstall the CLIpipinstallcreate-jupyter-gitUsageRun the CLI and specify in the path to where you want yourNEWGit repository createdcreate-jupyter-git<newrepositorypath>This repository will have a.gitignoreto ensure checkpoints aren't versioned. It also creates a.gitattributeswith a configuration for filtering and then adds.git/configvalues to utilize the Python scripts that handle the filtering viagit filter clean.Start Jupytercd <new repository path>
jupyter lab notebooksStart Jupyter with.venvThis setup is great for pulling in dependencies just for your Notebooks that don't clutter your global or personal python library space.Setup your.venvand allow your global or user Jupyter install to be utilized.cd <new repository path>
python3 -m venv .venv --system-site-packagesActivate the.venv:source.venv/bin/activateAdd your.venvas a Juypyter kernelpython-mipykernelinstall--user--name=.venvStart the Jupyter LabjupyterlabnotebooksCommit Your ChangesYou can create directories, notebooks, and fill your notebooks with wonderful code and generate beautiful output. When you are at a meaningful spot in your development simply do agit commit. The Git configurations that are inplace will filter out all output within your notebook files and stage them.If you push up to a remote repository like GitHub, you will see that the output fields in your notebooks are empty! Great!You will also notice GitHub does some cool magic to re-generate the output in a preview format for you when you view a*.ipynbfile. So you can still see the output in GitHub without storing it in your source. Neat!DevelopmentPublishingFirst bump the versionbumpversion--current-versionx.x.x<major|minor|patch>setup.pycreate_jupyter_git/__init__.pyNext generate the distribution filespythonsetup.pysdistbdist_wheelValidate the packagetwinecheckdist/*Upload the package for publicationtwineuploaddist/*