nbfilter
Filter .ipynb (nbformat) files to improve integration with version control systems (VCS), specifically git.
Setup
Install from PyPI:
pip install nbfilter
Use from the command line:
python -m nbfilter.clean < research.ipynb | sponge research.ipynb
Integrate into git:
From your repository's root directory:
Run the following command to define a filter called ipynbfilter in your .git/config settings:
git config filter.ipynbfilter.clean 'python -m nbfilter.clean'
Then run one of the following command sequences to trigger it for all files with the .ipynb extension:
printf '*.ipynb filter=ipynbfilter\n' >> .gitattributes # Apply filter for all contributors
git add .gitattributes
or:
printf '*.ipynb filter=ipynbfilter\n' >> .git/info/attributes # Apply filter for just me
To apply it to files that are already under source control (for example, so that diffing subsequent changes produces more intelligible results):
git add --renormalize . # (re-)apply filters to all files currently under source control
or:
git add --renormalize research.ipynb # (re-)apply filters to a single file
References / alternatives
-
Min RK's
nbstripoutgist that started it all (licensed as "Public Domain").git pre-commit hook for stripping output from IPython notebooks
-
nbstripoutis a PyPI-published package that provides all its functionality through anbstripoutconsole script. -
StackOverflow question: Using IPython notebooks under version control
-
Making Git and Jupyter Notebooks play nice uses
jqinstead of Python to do the JSON modifications, for the sake of speed. -
Jupyter notebooks and version control discusses alternatives to the
.ipynbfile format that would natively improvegit diff'ing (specifically, YAML with some additional constraints).
License
Copyright (c) 2018 Christopher Brown. MIT Licensed.
Release files for nbfilter 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nbfilter-1.1.0.tar.gz | 3.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nbfilter-1.1.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 7.6 kB
Release files / nbfilter-1.1.0.tar.gz
| Download URL | nbfilter-1.1.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2948b56d817dbc0c8212f38dad921e5ddfd496a375ce749bc2dd1583655eb7cf
|
|
BLAKE2b-256 checksum How to use checksums |
c47719ef3e2a3790e94d7b2ce9fb04e2208e7238ddaee00355e9f3ba3387d2cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
|
Release files / nbfilter-1.1.0-py2.py3-none-any.whl
| Download URL | nbfilter-1.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
7d9ac488a5c33c5ecd00c3e182bdf8be73b04e687e28d51745d396c51c2ce4b1
|
|
BLAKE2b-256 checksum How to use checksums |
9e9752286434d1f9c2ca46fb50bef1df74181e27eb24e7e6bf7ff86cc42388a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
|