Skip to main content

Don't let notebook cells run out of order

Project description

PyPI version Run tests Create a tag if version changed Publish to PyPi Build docs

enforce-notebook-run-order

Enforce the run order of Jupyter notebooks.

Jupyter notebooks are great for interactive data analysis. However, when they can encourage a bad habit: running cells out of order. This can lead to notebooks being committed to the repository in a state where they don't run from top to bottom, and other collaborators may receive different results when running the notebook from top to bottom.

enforce-notebook-run-order enforces the run order of a notebook by raising an exception if any cells are run out of order.

Installation

enforce-notebook-run-order can be installed via pip:

pip install enforce-notebook-run-order

It can also be set up as a pre-commit hook. See the pre-commit hook section for more details.

Usage

enforce-notebook-run-order can be used as a standalone script, or as a pre-commit hook.

Standalone

To use enforce-notebook-run-order as a standalone script, simply run it with the path to the notebook(s) you want to check:

nbcheck my_notebook.ipynb my_other_notebook.ipynb

Or point it to a directory to check all notebooks in that directory:

nbcheck my_notebooks/

If no paths are specified, nbcheck will check all notebooks in the current directory.

You can also use the full enforce-notebook-run-order command, but the nbcheck command is provided as a convenience.

pre-commit hook

To use enforce_notebook_run_order as a pre-commit hook, add the following to your .pre-commit-config.yaml:

repos:
-   repo: https://github.com/christopher-hacker/enforce-notebook-run-order
    rev: 1.7.0
    hooks:
    -   id: enforce-notebook-run-order

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

enforce_notebook_run_order-2.0.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file enforce_notebook_run_order-2.0.0.tar.gz.

File metadata

File hashes

Hashes for enforce_notebook_run_order-2.0.0.tar.gz
Algorithm Hash digest
SHA256 af76a44de976b19dbfa6475e0c94eef6ee54b741f354b742e573773e1d50a579
MD5 220840d8ad16df24fb3522dc4449c102
BLAKE2b-256 aff13e9abb99c75e8e17a7305bdde6e1316166f9a505b48513c0cca8795c4bf6

See more details on using hashes here.

File details

Details for the file enforce_notebook_run_order-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for enforce_notebook_run_order-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7554d8f4ec26c45f41c8a5f021edb02e39f8e8adea57adb40a0291ddb76c4bfd
MD5 63870f3e9da1804994128df37f72414b
BLAKE2b-256 e040ff26614d99352a886d5ff6a12cae84e0f4b8cf2a2cc69fbb7fc2898ad0d0

See more details on using hashes here.

Supported by

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