Skip to main content

Modify and run Jupyter notebooks from the command line

Project description

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.

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

nbclick-0.3.2.tar.gz (4.6 kB view details)

Uploaded Source

File details

Details for the file nbclick-0.3.2.tar.gz.

File metadata

  • Download URL: nbclick-0.3.2.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for nbclick-0.3.2.tar.gz
Algorithm Hash digest
SHA256 9c55ac63a5ed8ef7195b85ee4292875f186348e91425a7c3e4ae2baeb8cc9dd8
MD5 6e9012b4153501c94a9802571dc8ee29
BLAKE2b-256 8091aabedee90d80abadb9428bcbe4cc81e101839b56ebb22cd8cd43bb5fb87c

See more details on using hashes here.

Provenance

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