Skip to main content
See Build Status on Travis CI See Build Status on AppVeyor

nbsmoke

Basic notebook smoke tests: Do they run ok? Do they contain lint?

WARNING: early stage proof of concept; work in progress. Use at your own risk.

In particular, this extension is supposed to handle ipython magics as far as possible, but has not yet been widely tested.


This Pytest plugin was generated with Cookiecutter along with @hackebrot’s Cookiecutter-pytest-plugin template.

Installation

You can install nbsmoke via pip from PyPI:

$ pip install nbsmoke

Or you can install nbsmoke via conda from anaconda.org:

$ conda install -c pyviz/label/dev -c conda-forge nbsmoke

Usage

Check all notebooks in examples/ run without errors:

$ pytest --nbsmoke-run examples/

Check all notebooks in examples/ run without errors, and store html to look at afterwards:

$ pytest --nbsmoke-run --store-html=/scratch examples/

Lint check notebooks in examples/:

$ pytest --nbsmoke-lint notebooks/

Instead of all files in a directory, you can specify a list e.g.:

$ pytest --nbsmoke-run notebooks/Untitled*.ipynb

Additional options are available by standard pytest ‘ini’ configuration in setup.cfg, pytest.ini, or tox.ini:

[pytest]
# when running, seconds allowed per cell (see nbconvert timeout)
cell_timeout = 600

# notebooks to skip running; one case insensitive re to match per line
skip_run = ^.*skipme\.ipynb$
           ^.*skipmetoo.*$

# case insensitive re to match for file to be considered notebook;
# defaults to ``^.*\.ipynb``
it_is_nb_file = ^.*\.something$

nbsmoke supports # noqa comments to mark that something should be ignored during lint checking.

What’s the point?

Although more sophisticated testing of notebooks is possible (e.g. see nbval), just checking that notebooks run from start to finish without error in a fresh kernel (or on a neutral CI service) can be useful during development. Practical experience of working on several projects with notebooks confirms this, but that’s all the evidence I have.

Checking notebooks for lint might seem trivial/pointless, but it frequently uncovers unused names (typically unused imports). It’s also quite common to find python 2 vs 3 problems, and sometimes undefined names - in a way that’s faster than running the notebook (over multiple versions of python).

Unused imports/names themselves might seem trivial, but they can hinder understanding of a notebook by readers, or add dependencies that are not required.

Using # noqa: explanation in a notebook might seem like overkill, but the intention is to encourage unavoidable/desirable ‘mysterious imports’ to be clarified. E.g. if you’re importing something for its side effects, it’s very helpful to inform the reader of that.

Pyflakes is used as the underlying linter because “Pyflakes makes a simple promise: it will never complain about style, and it will try very, very hard to never emit false positives.”

Contributing

First, install using pip install -e .. Then run the tests using tox or pytest -v tests/.

New release to PyPI and anaconda.org: git tag -a vX.Y.Z -m "Something about release" && git push --tags.

License

Distributed under the terms of the BSD-3 license, “nbsmoke” is free and open source software.

Issues

If you encounter any problems, please file an issue (ideally including a copy of any problematic notebook).

Metadata

Release files for nbsmoke 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nbsmoke 0.2.2
File Size Uploaded Provenance Actions
nbsmoke-0.2.2.tar.gz 31.1 kB Without provenance Details for nbsmoke-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nbsmoke 0.2.2
File Interpreter ABI Platform Actions
nbsmoke-0.2.2-py2.py3-none-any.whl Python 3, Python 2 none any Details for nbsmoke-0.2.2-py2.py3-none-any.whl

Total release size: 43.7 kB

Release files / nbsmoke-0.2.2.tar.gz

Download URL nbsmoke-0.2.2.tar.gz
Size 31.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7b453243182038739eb12bb5a7ca3ac2bde5c9a3fcb79c9e4dc79df66d593247
BLAKE2b-256 checksum
How to use checksums
5b7e7f6e4cbb30172c05b8a75119e0fc63e13a5d1ff130a9b8e36c4a1e13f2cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / nbsmoke-0.2.2-py2.py3-none-any.whl

Download URL nbsmoke-0.2.2-py2.py3-none-any.whl
Size 12.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
eafbbad32ccbb12dd45951ed5d2b7e0a8a5e816be5170a1a69eadc2c7550b9b9
BLAKE2b-256 checksum
How to use checksums
977ee723a212246a5eb51211723d56dde38c2483a9e994fc12f2f5defa9c9aff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for nbsmoke 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page