Skip to main content

nbclick - Turn Jupyter notebooks into command line applications

License: MIT PyPI version

nbclick allows you to modify and run Jupyter notebooks from the commandline. It builds on top of nbparameterise which allows programmatic extraction and modification of parameters of Jupyter notebooks.

Installation

nbclick can be installed using pip:

python -m pip install nbclick

It is also possible to run nbclick without prior installation using pipx:

pipx run --system-site-packages nbclick

Note that the --system-site-packages flag is absolutely necessary if your notebook depends on any non-standard library Python package.

Running nbclick

After installation, you can run nbclick using the commandline:

nbclick

The most important argument is the NOTEBOOK parameter. For a given notebook, you can again use --help to display the configuration options:

nbclick mynotebook.ipynb --help

Preparing a notebook for execution with nbclick

nbclick relies on nbparameterise to extract command line options from your Jupyter notebook. The best way to specify customizable parameters is to place them into the first code cell of the notebook as simple assignments:

num_samples = 1000      # The number of samples to draw
outfile = "output.csv"  # The filename to store the results

For above case, the output of nbclick notebook.ipynb --help will be:

Usage: nbclick notebook.ipynb [OPTIONS]

Options:
  --num_samples INTEGER  The number of samples to draw  [default: 1000]
  --outfile TEXT         The filename to store the results  [default:
                         output.csv]
  --help                 Show this message and exit.

Limitations

There are a few known limitations that result from upstream projects that I currently do not plan to fix for nbclick:

  • The number of parameter types recognized is quite small. nbclick is known to work with int, float, bool, str, list (of both homogeneous and heterogeneous type). Most notably, nbparameterise does not support tuples.
  • List parameters are restricted to fixed length (defined by their default). This results from click voluntarily chosing not to provide variable length list parameters, as it introduces ambiguity of the parser.

Metadata

Release files for nbclick 0.4.1

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

Source distribution (sdist)

Source distribution for nbclick 0.4.1
File Size Uploaded
nbclick-0.4.1.tar.gz 8.1 kB Details

Release files / nbclick-0.4.1.tar.gz

Download URL nbclick-0.4.1.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
87aa6044ab2c78a929db5a82f94c7d5633174d4a7db3c88f462709a778d7af66
BLAKE2b-256 checksum
How to use checksums
bfd32c88fc6ebc4bd4b6c99be845beb279a9ca94b918a23caf541758053c1441
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.4.1 This release

1 release file

0.4.0

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

1 release file

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