Skip to main content

Papermill engine that executes notebooks inside Tenki Sandbox microVMs

Project description

papermill-tenki

A papermill engine that executes parameterized Jupyter notebooks inside disposable Tenki Sandbox microVMs.

Parameter injection happens locally in papermill as usual; the already parameterized notebook is uploaded to a fresh sandbox, executed there with jupyter nbconvert --execute, and the executed notebook (outputs, plots, errors) is downloaded and saved to papermill's output path. The sandbox is destroyed afterwards.

Install

pip install papermill-tenki

Setup

export TENKI_API_KEY=tk_...          # from your Tenki workspace settings
export TENKI_PROJECT_ID=...          # project to create sandboxes in

Usage

CLI:

papermill input.ipynb output.ipynb --engine tenki -p alpha 0.5

Python:

import papermill

papermill.execute_notebook(
    "input.ipynb",
    "output.ipynb",
    engine_name="tenki",
    parameters={"alpha": 0.5},
    # optional engine kwargs (override env vars):
    # project_id="...", image="...", sandbox_name="my-run",
    # cpu_cores=4, memory_mb=8192, bootstrap=False,
)

Configuration

Engine kwarg Env var Default Meaning
project_id TENKI_PROJECT_ID — (required) Tenki project the sandbox is created in
image TENKI_IMAGE Tenki default Sandbox image
sandbox_name papermill Sandbox display name
bootstrap TENKI_BOOTSTRAP enabled pip-install nbconvert/ipykernel when missing
cpu_cores Tenki default Sandbox CPU cores
memory_mb Tenki default Sandbox memory

TENKI_API_KEY is read by the Tenki SDK itself.

Notebook dependencies (numpy, pandas, ...) must exist in the sandbox: bake them into a custom image, or add a bootstrap cell at the top of the notebook. The kernel requested by the notebook must be installed in the sandbox; when it isn't and python3 is available, the engine falls back to python3 with a warning.

Timeouts

papermill's --start-timeout and --execution-timeout are forwarded to the remote nbconvert run (startup_timeout / timeout on the ExecutePreprocessor).

Tests

pip install -e .[dev]
pytest                       # unit tests, fully mocked, no network
TENKI_API_KEY=... TENKI_PROJECT_ID=... pytest tests/test_live_smoke.py   # live smoke test

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

papermill_tenki-0.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

papermill_tenki-0.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file papermill_tenki-0.1.0.tar.gz.

File metadata

  • Download URL: papermill_tenki-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for papermill_tenki-0.1.0.tar.gz
Algorithm Hash digest
SHA256 89c782113a615d65a07d5eba79d7e78e568a801688466b56dadd10249840836a
MD5 976eaf6e3beb62a5b0d4047461ea0697
BLAKE2b-256 9791e26bae1418daebc1aca7ea23da4c9192aa94bba3296f39d1aee01158a981

See more details on using hashes here.

File details

Details for the file papermill_tenki-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for papermill_tenki-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9cc3aa0ef1870d8f354e44fd7e1d762602d5e26bbb84e149f22473b171acee0f
MD5 e6ea308b89a8dc5956865adb47361fec
BLAKE2b-256 6e3973e65330793ab5424dcdaa5e89e477e9b3299fd1db157c6a6cccfcf8677c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page