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 (-p name value injects a notebook parameter, only if the notebook has a parameters cell that declares it):

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

Python:

import papermill

papermill.execute_notebook(
    "input.ipynb",
    "output.ipynb",
    engine_name="tenki",
    # notebook parameters — only for notebooks with a `parameters` cell; omit otherwise:
    parameters={"learning_rate": 0.5},
    # optional engine kwargs (override env vars); see Configuration below:
    # project_id="...", image="...", sandbox_name="my-run",
    # cpu_cores=4, memory_mb=8192,
)

bootstrap is enabled by default and installs the jupyter toolchain in the sandbox for you — only set bootstrap=False if your image already has it.

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.1.tar.gz (7.7 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.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: papermill_tenki-0.1.1.tar.gz
  • Upload date:
  • Size: 7.7 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.1.tar.gz
Algorithm Hash digest
SHA256 d12d00c1a38a801b71ea35c599e53cb888668e2f0df0358209f402cef4cbf054
MD5 ffc95ffd304fcdb03647cf4e09d4b059
BLAKE2b-256 3f66437bb67b0b88cfe1b0b914545eb7453ded71ddb58faab663689accf1cb50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for papermill_tenki-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cec12103dc4681dcb512ca4b585dada076d48900ab02320d7a35e407e2c7b1a7
MD5 e22dc965636f2509818416118fada899
BLAKE2b-256 66354c0f8a6b8cf3ce1fd237ac06dece395d92f7b686251f7bde71017c115c7a

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