Skip to main content

Re-run a notebook substituting input parameters in the first cell.

Project description

This is a tool to run notebooks with input values. When you write the notebook, these are defined in the first code cell, with regular assignments like this:

stock = 'YHOO'
days_back = 600

Nbparameterise handles finding and extracting these parameters, and replacing them with input values. You can then run the notebook with the new values. This can be used for:

  • Batch processing: run the same code on a list of different inputs. See examples/batch.py.

  • Simple user interfaces: build an input form based on the parameters, and run the notebook when the user submits the form. See examples/webapp.py for an implementation of this with an HTML form.

Extra information about the parameters, such as names to display in a user interface, can be stored in notebook metadata.

Nbparameterise is written in Python 3, but it can handle notebooks that use Python 2.

Usage:

import nbformat
from nbparameterise import (
    extract_parameters, replace_definitions, parameter_values
)

with open("Stock display.ipynb") as f:
    nb = nbformat.read(f, as_version=4)

# Get a list of Parameter objects
orig_parameters = extract_parameters(nb)

# Update one or more parameters
params = parameter_values(orig_parameters, stock='GOOG')

# Make a notebook object with these definitions, and execute it.
new_nb = replace_definitions(nb, params)

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

nbparameterise-0.3.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

nbparameterise-0.3-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file nbparameterise-0.3.tar.gz.

File metadata

File hashes

Hashes for nbparameterise-0.3.tar.gz
Algorithm Hash digest
SHA256 e098a18bf231de99c290df3fa439f11e6872914f48f331ea521c94b588e99959
MD5 da6b459ffd5099dffd832f11e62ddfc9
BLAKE2b-256 217554a2f927351eed9cc7ac0afbeec4e8db55f6a2fd929500771bbcf91c47d3

See more details on using hashes here.

File details

Details for the file nbparameterise-0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for nbparameterise-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 041f41f1fcc40d1032c92cdadd4fec8779417239be7a1d13971ddcabb520f4e3
MD5 70c0ed4892d16be642e313ecfa6cb349
BLAKE2b-256 1b00cd588e2fbf2fd7ef516eea35250995c9d9b7a4a25213534eb6ebc9a6c677

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