Clean Jupyter notebooks for versioning
Project description
nb-clean
nb-clean cleans Jupyter notebooks of cell execution counts, metadata, and
outputs, preparing them for committing to version control. It provides a Git
filter to automatically clean notebooks before they are staged, and can also be
used as a standalone tool outside Git or with other version control systems. It
can determine if a notebook is clean or not, which can be used as a check in
your continuous integration pipelines.
Installation
To install the latest release from PyPI, use pip:
python -m pip install nb-clean
Alternately, in Python projects using Poetry or Pipenv for dependency
management, add nb-clean as a development dependency with
poetry add --dev nb-clean or pipenv install --dev nb-clean. nb-clean
requires Python 3.6 or later.
Usage
Cleaning
To install a filter in an existing Git repository to automatically clean notebooks before they are staged, run the following from the working tree:
nb-clean configure-git
nb-clean will configure a filter in the Git repository in which it is run, and
will not mutate your global or system Git configuration. To remove the filter,
run:
nb-clean unconfigure-git
Aside from usage from a filter in a Git repository, you can also clean up a Jupyter notebook manually with:
nb-clean clean -i original.ipynb -o cleaned.ipynb
or by passing the notebook contents on stdin:
nb-clean clean < original.ipynb > cleaned.ipynb
Checking
You can check if a notebook is clean with:
nb-clean check -i notebook.ipynb
or by passing the notebook contents on stdin:
nb-clean check < notebook.ipynb
nb-clean will exit with status code 0 if the notebook is clean, and status
code 1 if it is not. nb-clean will also print details of cell execution
counts, metadata, and outputs it finds.
Copyright
Copyright © 2017-2020 Scott Stevenson.
nb-clean is distributed under the terms of the ISC licence.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nb-clean-1.4.3.tar.gz.
File metadata
- Download URL: nb-clean-1.4.3.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.8.2 Darwin/19.4.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae0fa7af516e0eb06c2875afe262e312d353cee855fb361e95155e3aa2d791b0
|
|
| MD5 |
ed42fa417f917ac938a0462bdaec2028
|
|
| BLAKE2b-256 |
0a02f971e4b4ae600600c86499b92aecaa91cd54d3b757df39f3b4e89eda8ac8
|
File details
Details for the file nb_clean-1.4.3-py3-none-any.whl.
File metadata
- Download URL: nb_clean-1.4.3-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.8.2 Darwin/19.4.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40639d4d27e4a91ad8435c36ea810e4d1b3466318d19d72c4851ecd7fc3fa723
|
|
| MD5 |
2484f9c6bf1dc27e357f7bb9db9af4f9
|
|
| BLAKE2b-256 |
63c6f93b706b1e1553f9e26b14eacb76036dc01bf480c40c674dd5fbbc539cd1
|