• Stars
    star
    5,960
  • Rank 6,776 (Top 0.2 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created over 7 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

📚 Parameterize, execute, and analyze notebooks

CI CI image Documentation Status badge badge PyPI - Python Version Code style: black papermill Anaconda-Server Badge pre-commit.ci status

papermill is a tool for parameterizing, executing, and analyzing Jupyter Notebooks.

Papermill lets you:

  • parameterize notebooks
  • execute notebooks

This opens up new opportunities for how notebooks can be used. For example:

  • Perhaps you have a financial report that you wish to run with different values on the first or last day of a month or at the beginning or end of the year, using parameters makes this task easier.
  • Do you want to run a notebook and depending on its results, choose a particular notebook to run next? You can now programmatically execute a workflow without having to copy and paste from notebook to notebook manually.

Papermill takes an opinionated approach to notebook parameterization and execution based on our experiences using notebooks at scale in data pipelines.

Installation

From the command line:

pip install papermill

For all optional io dependencies, you can specify individual bundles like s3, or azure -- or use all. To use Black to format parameters you can add as an extra requires ['black'].

pip install papermill[all]

Python Version Support

This library currently supports Python 3.8+ versions. As minor Python versions are officially sunset by the Python org papermill will similarly drop support in the future.

Usage

Parameterizing a Notebook

To parameterize your notebook designate a cell with the tag parameters.

enable parameters in Jupyter

Papermill looks for the parameters cell and treats this cell as defaults for the parameters passed in at execution time. Papermill will add a new cell tagged with injected-parameters with input parameters in order to overwrite the values in parameters. If no cell is tagged with parameters the injected cell will be inserted at the top of the notebook.

Additionally, if you rerun notebooks through papermill and it will reuse the injected-parameters cell from the prior run. In this case Papermill will replace the old injected-parameters cell with the new run's inputs.

image

Executing a Notebook

The two ways to execute the notebook with parameters are: (1) through the Python API and (2) through the command line interface.

Execute via the Python API

import papermill as pm

pm.execute_notebook(
   'path/to/input.ipynb',
   'path/to/output.ipynb',
   parameters = dict(alpha=0.6, ratio=0.1)
)

Execute via CLI

Here's an example of a local notebook being executed and output to an Amazon S3 account:

$ papermill local/input.ipynb s3://bkt/output.ipynb -p alpha 0.6 -p l1_ratio 0.1

NOTE: If you use multiple AWS accounts, and you have properly configured your AWS credentials, then you can specify which account to use by setting the AWS_PROFILE environment variable at the command-line. For example:

$ AWS_PROFILE=dev_account papermill local/input.ipynb s3://bkt/output.ipynb -p alpha 0.6 -p l1_ratio 0.1

In the above example, two parameters are set: alpha and l1_ratio using -p (--parameters also works). Parameter values that look like booleans or numbers will be interpreted as such. Here are the different ways users may set parameters:

$ papermill local/input.ipynb s3://bkt/output.ipynb -r version 1.0

Using -r or --parameters_raw, users can set parameters one by one. However, unlike -p, the parameter will remain a string, even if it may be interpreted as a number or boolean.

$ papermill local/input.ipynb s3://bkt/output.ipynb -f parameters.yaml

Using -f or --parameters_file, users can provide a YAML file from which parameter values should be read.

$ papermill local/input.ipynb s3://bkt/output.ipynb -y "
alpha: 0.6
l1_ratio: 0.1"

Using -y or --parameters_yaml, users can directly provide a YAML string containing parameter values.

$ papermill local/input.ipynb s3://bkt/output.ipynb -b YWxwaGE6IDAuNgpsMV9yYXRpbzogMC4xCg==

Using -b or --parameters_base64, users can provide a YAML string, base64-encoded, containing parameter values.

When using YAML to pass arguments, through -y, -b or -f, parameter values can be arrays or dictionaries:

$ papermill local/input.ipynb s3://bkt/output.ipynb -y "
x:
    - 0.0
    - 1.0
    - 2.0
    - 3.0
linear_function:
    slope: 3.0
    intercept: 1.0"

Supported Name Handlers

Papermill supports the following name handlers for input and output paths during execution:

Development Guide

Read CONTRIBUTING.md for guidelines on how to setup a local development environment and make code changes back to Papermill.

For development guidelines look in the DEVELOPMENT_GUIDE.md file. This should inform you on how to make particular additions to the code base.

Documentation

We host the Papermill documentation on ReadTheDocs.

More Repositories

1

nteract

📘 The interactive computing suite for you! ✨
TypeScript
6,204
star
2

hydrogen

:atom: Run code interactively, inspect data, and plot. All the power of Jupyter kernels, inside your favorite text editor.
TypeScript
3,924
star
3

semiotic

A data visualization framework combining React & D3
JavaScript
2,434
star
4

commuter

🚎 Notebook sharing hub
JavaScript
493
star
5

testbook

🧪 📗 Unit test your Jupyter Notebooks the right way
Python
418
star
6

scrapbook

A library for recording and reading data in notebooks.
Python
281
star
7

vdom

🎄 Virtual DOM for Python
Jupyter Notebook
222
star
8

bookstore

📚 Notebook storage and publishing workflows for the masses
Python
202
star
9

data-explorer

The Data Explorer is nteract's automatic visualization tool.
TypeScript
103
star
10

sidecar

🚤 Little side display of Jupyter kernel rich output
JavaScript
90
star
11

ansi-to-react

💂‍♂️ ANSI to React
TypeScript
88
star
12

nteract.io

📣 Our site! 📣
JavaScript
44
star
13

dx

Data Explorer for Python
Python
37
star
14

create-nteract-app

⚡ Create an nteractive application with zero configuration
JavaScript
35
star
15

pick

⛏ Customize your kernels on Launch!
Jupyter Notebook
32
star
16

semiotic-docs

Docs for using Semiotic
JavaScript
32
star
17

commutable

♻️ Operations for Immutable Notebook Documents
29
star
18

mathjax-electron

🔣:electron: A trimmed down version of the MathJax library for use with electron and modern browsers
JavaScript
28
star
19

examples

Example nteract notebooks with links to execution on mybinder.org
Jupyter Notebook
27
star
20

outputs

A collection of React components for displaying rich Jupyter display objects
TypeScript
26
star
21

nteract-next

Iterating on the next version of nteract
TypeScript
22
star
22

coffee_boat

☕⛵WIP PySpark dependency management
Jupyter Notebook
22
star
23

docs

🏖 User written and user focused documentation for working with nteract! Join us!
HTML
18
star
24

nes

🎮 Notebook Enterprise Summit
18
star
25

initiatives

📑 Top level initiatives that our team is working on
17
star
26

spawnteract

🚸 Spawn Jupyter Kernels
JavaScript
15
star
27

mathjax

React context wrapper around the MathJax API
TypeScript
15
star
28

papermillr

R bindings for papermill
R
14
star
29

notebook-preview

🎥 [DEPRECATED] Lightweight preview of a notebook, nteract style
JavaScript
14
star
30

global-sprint

🌐 Build. Share. Learn. 🗓 July 28 - August 3 2018
13
star
31

ick

🏮 Interactive Console Experiments
JavaScript
13
star
32

rx-jupyter

🎈 RxJS 5 bindings for the Jupyter Notebook API
13
star
33

play

The code base for the nteract Play app
JavaScript
13
star
34

transformime

🚚 Mimetype + data -> HTMLElement
13
star
35

ion

A React-backed UI Toolkit
JavaScript
12
star
36

snakestagram

🐍 📦 Snake in a box, conda environments to go
Shell
12
star
37

docs-old

📔 docs are awesome DEPRECATED - ARCHIVE ON 11-30-2018
12
star
38

kernel-relay

kernel-relay is a GraphQL service for interfacing with one or more Jupyter kernels
TypeScript
12
star
39

term-launcher

💻 🚀 Launch terminals and jupyter consoles from node.
JavaScript
10
star
40

enchannel

💱 standardizing how a frontend communicates with a kernel
JavaScript
10
star
41

kernelspecs

📇 Find Jupyter kernelspecs on a system
JavaScript
9
star
42

markdown

A package for rendering Markdown within Jupyter notebooks
TypeScript
9
star
43

meeting-minutes

📝 Minutes from nteract monthly contributor meeting; reports and metrics
9
star
44

cabinet

📕 Exploring a new notebook container format
9
star
45

jupyter-paths

🌇 Pure JavaScript implementation of jupyter --paths --json
JavaScript
9
star
46

oauth-server

🔏 Little OAuth Handler for Gist Publishing
JavaScript
8
star
47

react-jupyter-display-area

📊 Jupyter Display Area as a React Component
7
star
48

improved-spark-viz

🐼 WIP Improved visualizations in Spark
Python
7
star
49

jupyter-display-area

🚫 Prototype Web Component for Jupyter Display Areas
JavaScript
6
star
50

logos

✨ A place to collaborate on nteract logos ✨
TypeScript
6
star
51

ipypandex

A package for automatically turning on Data Explorer in Pandas for an IPython Jupyter kernel.
Python
6
star
52

transformime-react

🚫 Mimetype + data -> React Element
5
star
53

jupyer-go-api

Jupyter API server implemented in Go
Go
5
star
54

enchannel-zmq-backend

ZeroMQ backend implementation for enchannel
TypeScript
5
star
55

graphql-schema-exploration

Exploring a GraphQL schema for notebooks
TypeScript
5
star
56

education

Developing strategies, designs, and curriculum to reach more and teach more
4
star
57

nteract.github.io

:octocat: GitHub Pages for nteract *** DEPRECATED - See https://github.com/nteract/nteract.io ***
CSS
4
star
58

any-vega

Interface with any vega or vega-lite version
JavaScript
4
star
59

galleria

GitHub bot that uploads screenshots from PR builds
JavaScript
4
star
60

ui-refresh

TypeScript
4
star
61

nteract-monthly-newsletter

Plain-text versions of the nteract monthly newsletter
3
star
62

inodejs

Experimenting with jp-kernel
Jupyter Notebook
3
star
63

notebook-render

TypeScript
3
star
64

minimal-plotly

📊 A minimal version of the plotly library
JavaScript
3
star
65

commuter-on-glitch

Running commuter on glitch.me
3
star
66

jupyter-kernel-launcher

Launches Jupyter kernels from a Node environment
CoffeeScript
3
star
67

libzmq-win

📦 Windows binaries of the ØMQ library
3
star
68

directory-listing

A set of React components for creating directory list views in nteract-based applications
TypeScript
3
star
69

design

✏️ Mocking up nteract UI and UX
3
star
70

transformime-jupyter-transformers

🚫 Transformers for Jupyter-specific MIME types.
JavaScript
3
star
71

desktop-integration-tests

Testing nteract for desktop on the regular with a full test suite
Jupyter Notebook
2
star
72

ipython-paths

🌆 Paths for IPython before Jupyter 4.0
JavaScript
2
star
73

jupyter-session

A tool for interacting with Jupyter kernels
CoffeeScript
2
star
74

models

Exploring the Python side of nteract's setIn based models
2
star
75

specs

📑 Specifications for APIs, processes, and protocols.
2
star
76

zmq-static

🚫 Statically linked bindings for node.js and io.js to ZeroMQ
JavaScript
2
star
77

associator

👥 Associates file extensions to an application
JavaScript
2
star
78

content-providers

A collection of content providers for accessing notebooks in different storage locations
2
star
79

notebook-test-data

📚 Jupyter notebook test data. Feel free to add more!
Jupyter Notebook
2
star
80

transformime-commonmark

🚫 Transformer using commonmark.js
JavaScript
2
star
81

dx_jlab

dx on JupyterLab
Python
1
star
82

assets

📦 static assets for nteract/nteract
CSS
1
star
83

enchannel-in-memory

💻 In memory enchannel backend
1
star
84

octicons

GitHub Octicons set packaged as React components.
TypeScript
1
star
85

vega-embed-v2

Bundled embedded Vega 2 and Vega-Lite 1
JavaScript
1
star
86

commutable-perf

🐢 Addressing performance of the commutable library
Python
1
star
87

naming

📛 Shipping releases with style
1
star
88

ui-web

UI Repo for web and play components.
TypeScript
1
star
89

fs-observable

An Observable wrapper around Node's fs APIs
TypeScript
1
star
90

enchannel-socketio-backend

🔌 enchannel powered by socket.io, to be used with kernel-relay
JavaScript
1
star
91

styled-blueprintjsx

npm package that wraps Blueprint stylesheets as a styled-component global style to avoid needing a CSS loader
TypeScript
1
star
92

design-docs

Design docs for the nteract ecosystem
1
star
93

jupyter-transport-wrapper

A thin wrapper abstracting over ZMQ and (evenutally) websockets for Jupyter
JavaScript
1
star
94

commutable-models

♻️ 📘 Experimenting with commutable and flow-immutable-models
JavaScript
1
star