Strips outputs from Jupyter notebooks
Project description
nbstripout-fast
A much faster version of nbstripout by writing it in rust (of course). This helps strip Jupyter Notebook output and metadata from notebooks. It is very useful as a git filter and is highly configurable.
Installation
pip install nbstripout-fast
Then replace nbstripout-fast with anywhere you use nbstripout.
Key differences
- While we mirrored most of nbstripout's API, we do not support every nbstripout option.
- There is no CLI option to install this in git for you
- We support repository level settings in a
.git-nbconfig.yaml
file. Check out ourexamples
. On a high level, you can add a git filter in a sitewide/user level and then allow each project to enforce consistent settings.
Why Rust?
nbstripout is a excellent project, but the python startup and import time makes its usage at scale a bit painful. While this means giving up on using nbconvert under the hood and ensuring the notebook is the correct format, it does make things up to 200x faster. This matters when you have a large number of files and git filter is called sometimes more than once per file. Let's look at the data:
Cells | nbstripout | nbstripout_fast |
---|---|---|
1 | 0m0.266s | 0m0.003s |
10 | 0m0.258s | 0m0.003s |
100 | 0m0.280s | 0m0.004s |
1000 | 0m0.372s | 0m0.013s |
10000 | 0m1.649s | 0m0.133s |
The table above shows a large overhead per notebook (mostly python startup time). When you have 100 or more notebooks, nbstripout takes more than 40s while nbstripout-fast takes only 1s!
Developing
You can use cargo which will build + run the CLI:
cargo run -- -t examples/example.ipynb
You can also build with cargo and run the script with the full path:
cargo build # dev build - ./target/debug/nbstripout-fast
cargo build --release # release build - ./target/release/nbstripout-fast
Running unit tests: maturin builds this repo to include pyo3 bindings by default. This allows for us to have an extension python extension mode as well. As of today, we can't have a binary and an extension, so we use the extension only for testing (issue).
pip install -e .
maturin develop
# Should output, this way you can use RUST_LOG=debug
in-venv pytest -rP
Debugging
Use RUST_LOG=debug to debug script for example:
RUST_LOG=debug cargo run -- '--extra-keys "metadata.bar cell.baz" -t foo.ipynb'
Releasing
Manylinux, macos, and windows wheels and sdist are built by github workflows. Builds are triggered upon the creation of a pull request, creating a new release, or with a manual workflow dispatch. The wheels and sdist are only uploaded to PyPI when a new release is published. In order to create a new release:
- Create a commit updating the version in
Cargo.toml
andCHANGELOG.md
, then create a git tag:
git tag vX.Y.Z
git push --tags
- Draft a new release in github; select the tag that you just created.
- Once the new release is created, the wheels and sdist will be built by a
github workflow and then uploaded to PyPI automatically using the
PYPI_API_TOKEN
in the github secrets for the repository.
History
This plugin was contributed back to the community by the D. E. Shaw group.
License
This project is released under a BSD-3-Clause license.
We love contributions! Before you can contribute, please sign and submit this Contributor License Agreement (CLA). This CLA is in place to protect all users of this project.
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
Built Distributions
Hashes for nbstripout_fast-1.0.2-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e795ebceab2a56747cff16613a48c0910ac1430e567dc9e185e13a81c582358 |
|
MD5 | b772bff735e970da2b8668d7560b7674 |
|
BLAKE2b-256 | 32fd51a16c86500e79529dc160b56c572cb6c49294138040d22daa169ce8627c |
Hashes for nbstripout_fast-1.0.2-cp311-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99da36f5bde25772560d5a4035d57a4461b5df49695c1022e8c4bed93e09f595 |
|
MD5 | d3d5d3945dde7473cfe8363e8698b378 |
|
BLAKE2b-256 | 0ed8df8e69d65d298c6b92620231f89a0447f95a3ebae164db1540901da87337 |
Hashes for nbstripout_fast-1.0.2-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8934f765af507f3b9233c4b3795933047c32320b18332ca58c3fdf0d0dc8023 |
|
MD5 | 9e9ef7236ab5f0030d7d8229996395a4 |
|
BLAKE2b-256 | a8f7040d8eebc6819c04ec64b57ec74519523f412eb905b323664b5a8bce32bd |
Hashes for nbstripout_fast-1.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41f42686ae3662437a732cdb066e0b4e5e5054746b1b4fb81f6f5369a22ee9d3 |
|
MD5 | e889ce4797a31e893fa4d47e8aafa6f8 |
|
BLAKE2b-256 | 5dcb1aaebfdafb99d4fd088eb2413d6f5b0c709a044e82e89ed73419a6a8d02b |
Hashes for nbstripout_fast-1.0.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b53b8fc5ecf31be2bce47b6077814baed9622e94389c7cba2a500717eff2ac49 |
|
MD5 | 057f55718425e2f534d573f64f79e55f |
|
BLAKE2b-256 | 4bbb69a043c9da7c862701a2720f00884428d1c0bef51b2dc5a0d0b62455bde0 |
Hashes for nbstripout_fast-1.0.2-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8858591b25dae608298eaeb80076950eace19312fefa50c524b555b6a1d57727 |
|
MD5 | 6b78f77b61e8a52835605f38d15bfacf |
|
BLAKE2b-256 | 60d6dd5a188e164afb58cf499dcf7bb2025acaa97b99b1e3d49fd9b8ac68390d |
Hashes for nbstripout_fast-1.0.2-cp310-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b8f3601a35f584902bc72f35ce13adafac6e16d3b8574e38082dca736210f5d |
|
MD5 | b8c664fce0df5f586fedcd4d94c49349 |
|
BLAKE2b-256 | 7877ccc9011676ac10a128f7d37cce2f925cbd7807cb7cf3046194be271ea8a2 |
Hashes for nbstripout_fast-1.0.2-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac877dc7137a36c3216c24d42529734ae7c413421948925571a69e17a754928f |
|
MD5 | 3a95ba9a5945f4c4712049ddbb088baa |
|
BLAKE2b-256 | fcb61e1ba56a2851097cdfa9aff097265faf0ed95aad421e84441ffe757e0443 |
Hashes for nbstripout_fast-1.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17a1e399fb079498f97700a35c0d0aa9327ab78974d8a65f4b3234b2ab1d0053 |
|
MD5 | fa319ea4dcd986dcf6c4661c280d1d1f |
|
BLAKE2b-256 | da7d97c4f8aa26fa83d90a0698c5b15860039442857b158ea9537ad15e292062 |
Hashes for nbstripout_fast-1.0.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8be95b33598930908597cadb3e91ed8ca3a35cf0970b5494f67867d025c0c977 |
|
MD5 | aa3b6f9cce4f4ebde0ece063c2454082 |
|
BLAKE2b-256 | 846e3c4bfd5238bc3f17f6ab4142ffcd5552a1bf1ab9bfca40cc50cc16ef17ef |
Hashes for nbstripout_fast-1.0.2-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4085398026d51cf3896adffab53f948136f75d867ded563719f66767e0bcf59 |
|
MD5 | bcff37e6604be87d789d34b61f85b373 |
|
BLAKE2b-256 | 7b03d3ff2f9bda6be8531103c8aa1b1100abb3fe2f056f30eb2181c2867c2f74 |
Hashes for nbstripout_fast-1.0.2-cp39-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ecbf8e82ee58372c0a0e8d48679755a05067aad57db106aee4f55d586c9cce3 |
|
MD5 | e42febb34ca4d9af98e83372647d94d1 |
|
BLAKE2b-256 | 2bcaee1ade503b5da264067fdb2a7e695a0027f8344a1fdbfe869518f284c4c9 |
Hashes for nbstripout_fast-1.0.2-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d59cec1d15bbbda3bbe6544af1cdcb8bd7cef456cec609bc5218a18394931ce4 |
|
MD5 | a3cde826d32e0270b6356b61143957dd |
|
BLAKE2b-256 | b504ba36180725924de3d96f9815fded3ecd055b20cd419387793acd9574bf0f |
Hashes for nbstripout_fast-1.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85aca18654b50f0aad773c32f164f01b5b2f01f22d7d71651746a43ccb012bad |
|
MD5 | 00e20dfe1a2c03b69dc72f4134f9cdf0 |
|
BLAKE2b-256 | d6113ca42773a71c82f8c96aa220ed9f0805607369442499320d1c08e4ebd31e |
Hashes for nbstripout_fast-1.0.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 079f91e7e1b495c7b0db827e9e593e7f309bbaf059364d80c0b638bd50259e13 |
|
MD5 | 33f1b055d0864d4679b00788cc19f14f |
|
BLAKE2b-256 | e5cd811ab3f5d1dcb0f52532009c48c703785dfb5b206fe601f4b910fd576c0e |