Skip to main content

Papermill Jupyter report

PyPI Install with conda Github Actions Status

Microservice to generate Jupyter reports by executing notebook and exporting them to static HTML page combining papermill and nbconvert.

It can be run as a standalone application or as a JupyterHub service.

Demo

The workflow is described in the figure below. You can either:

  1. Set a specific URL to select a notebook and pass query arguments as parameters,
  2. Or interactively select one notebook and set its parameters.

Features

The API is described there.

There are two features provided by this service:

  • Listing all available report templates (and their parameters) The available templates are all notebook files existing within the template_root_dir.
  • Generate a report (i.e. execute a parametrized notebook and convert it to HTML)

Parametrized notebook are supported only for Python notebook.

Configuration

The configurable settings for the service are:

  • broken_reports_dir: Folder in which broken notebook will be copied - it must be a subfolder of notebook_dir; default /home/USERNAME/broken_reports
  • config_file: Configuration file name; default papermill_service_config
  • git_auth: Git authentication (username:password); default None
  • notebook_dir: Notebook server root directory; default /home/USERNAME This is needed to build the link to broken notebook.
  • port: Port of the service; default 8888
  • template_root_dir: Folder containing the notebook templates on the server; default /opt/papermill_report
  • template_dir: Folder of the Git repository containing the notebook templates; default "."
  • template_git_url: Git repository URL source of the notebook templates; default None
  • template_paths: Paths to search for service webpage jinja templates, before using the default templates; default None

The string USERNAME will be replaced with the user’s username if used in broken_reports_dir or notebook_dir.

Notes

  • On Unix platforms, the service must be run as root because report processes are executed through su <user> --login command to impersonate the authenticated user and setting the environment variables afresh.

Development

This python package is meant to be deployed as a JupyterHub Hub-Managed service.

The consequences are:

  • The service runs its own tornado server. Requests will be forwarded to it by the JupyterHub internal proxy from the standard URL https://myhub.horse/services/my-service/ (pay attention to the required trailing /).
  • Authentication is deferred to JupyterHub
  • As it is managed by JupyterHub, JupyterHub will check that the service is alive. And if not, it will restart it. Moreover, when JupyterHub is nicely stopped, it will stop the service.

Testing

There is 2 levels of test in this service. Some conventional unit tests with pytest and a Dockerfile to spin an integrated environment starting the service as JupyterHub service.

Unit test

python -m install -r requirements.txt -r requirements_dev.txt
pytest papermill_report

Integration with JupyterHub

To build and launch the integrated environment:

docker build -t papermill-report .
docker run -p 8000:8000 --rm papermill-report

The Hub is parameterized (see jupyterhub_config.py) with two users:

  • jovyan: an administrator
  • marc: an user

There are no password on the accounts.

The template folder is the examples folder of this project.

You can also test the service manually by visiting valid endpoints:

  • http://localhost:8000/services/report/
  • http://localhost:8000/services/report/broken_parameters.ipynb
  • http://localhost:8000/services/report/no_parameters.ipynb
  • http://localhost:8000/services/report/subfolder/simple_execute.ipynb&msg=hello

Integration tests can be executed automatically using that environment with the following command:

docker-compose -f e2e-tests/docker-compose.yml run e2e ./e2e-tests/run_e2e.sh
docker-compose -f e2e-tests/docker-compose.yml down

Metadata

Release files for papermill-report 2.0.5

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

Source distribution (sdist)

Source distribution for papermill-report 2.0.5
File Size Uploaded
papermill_report-2.0.5.tar.gz 2.2 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for papermill-report 2.0.5
File Interpreter ABI Platform
papermill_report-2.0.5-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 2.3 MB

Release files / papermill_report-2.0.5.tar.gz

Download URL papermill_report-2.0.5.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
97780d215c940c74f9143f57039f87dda85b4b7dd39bd24507461e937aa44c22
BLAKE2b-256 checksum
How to use checksums
9b93f09f7d79623fc5d8799fa7c95eeaf425a16b9f86b42c83068e7f8e2f1b6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.0

Release files / papermill_report-2.0.5-py2.py3-none-any.whl

Download URL papermill_report-2.0.5-py2.py3-none-any.whl
Size 60.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
6948f9cd66c68f3f0021b98cd949f778d8eca5e15cf4896719a25fa44ee816ac
BLAKE2b-256 checksum
How to use checksums
ebbbd98104c07bde4f5f288b771bcae58d3b3093eb63a3663ce4e951f862edd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.0

Release history Release notifications | RSS feed

This release

2.0.5 This release

2 release files

2.0.4

2 release files

2.0.3

2 release files

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