Skip to main content

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:

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-2019 Scott Stevenson.

nb-clean is distributed under the terms of the ISC licence.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nb-clean-1.4.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nb_clean-1.4.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file nb-clean-1.4.0.tar.gz.

File metadata

  • Download URL: nb-clean-1.4.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.15 CPython/3.7.3 Darwin/18.5.0

File hashes

Hashes for nb-clean-1.4.0.tar.gz
Algorithm Hash digest
SHA256 c6cea5092516197ad4cf42be31ed5662ddee8f7a317b82ee98101b77db9d74a5
MD5 14b279d8f9d0d6b725626e135145a9ed
BLAKE2b-256 f6770769d3b2b50eaa46e7742d3c91ff50bf462994df4dffbe06ceea1de0fe23

See more details on using hashes here.

File details

Details for the file nb_clean-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: nb_clean-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.15 CPython/3.7.3 Darwin/18.5.0

File hashes

Hashes for nb_clean-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a0a0661ab162e893fe8d41c59fa03c8b9dca89b2485f401d3a5089c1c147bec
MD5 81378260c82257ef8e4a2ca80aeeb5ea
BLAKE2b-256 4b7013047f151950673eb7f00e9281021318116dea7e60afb0e961c23af7db55

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page