Skip to main content

JupyterLab extension for hot patching externally modified notebooks

Project description

hot-notebook-patching

PyPI version PyPI - Python Version

A JupyterLab extension for hot patching notebooks that are edited externally, for example by an AI coding agent like Claude Code.

Instead of triggering a full notebook reload (which restarts the kernel and clears widget state), only the cells that actually changed are patched into the live notebook model.

https://github.com/user-attachments/assets/6e287a55-41ff-48c0-a48c-f7a56d708413

What it does

Claude Code edits notebook.ipynb on disk
          ↓
Extension detects the file change
          ↓
Only modified cells are patched
          ↓
Kernel keeps running · Widget state intact · Scroll position preserved

Installation

Requires JupyterLab 4.

pip install hot-notebook-patching

Then restart JupyterLab (or start it fresh) — the extension is prebuilt, no jupyter labextension build step needed.

To uninstall:

pip uninstall hot-notebook-patching

Usage

Toolbar button

Each notebook gets a ⚡ bolt button in the toolbar. Click it to toggle auto-patch mode — the extension will watch the file for changes and patch automatically.

Commands

Action How
Patch once from disk Toolbar ⚡ button (when auto-patch is off) · Cmd/Ctrl+Alt+P inside a notebook · Command Palette → Patch Notebook From Disk
Toggle auto-patch Toolbar ⚡ button · Command Palette → Toggle Auto-Patch on File Change

What is preserved

  • Running kernel
  • Widget state (ipywidgets, anywidget, …)
  • Cell outputs and execution counts
  • Scroll position

What is updated

  • Cell source code (with line-level diff indicators)
  • Cell metadata
  • Added / deleted / reordered cells

Development

# Terminal 1: rebuild on every source change
source .venv/bin/activate
jlpm watch

# Terminal 2: start JupyterLab
source .venv/bin/activate
jupyter lab

After each rebuild, hard-refresh the browser tab (Cmd+Shift+R) — no server restart needed.

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

hot_notebook_patching-0.2.2.tar.gz (133.8 kB view details)

Uploaded Source

Built Distribution

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

hot_notebook_patching-0.2.2-py3-none-any.whl (28.1 kB view details)

Uploaded Python 3

File details

Details for the file hot_notebook_patching-0.2.2.tar.gz.

File metadata

  • Download URL: hot_notebook_patching-0.2.2.tar.gz
  • Upload date:
  • Size: 133.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for hot_notebook_patching-0.2.2.tar.gz
Algorithm Hash digest
SHA256 1b932b6e870cf35613611703f64fd7de90e92cfd7d1def47b6e6b0d5eada5597
MD5 b71562d662137927530b76481fddf07b
BLAKE2b-256 0f7a2aec536fc1f39b4ed436fa23f8d65de7899f00d01d835f8a736e084f40e6

See more details on using hashes here.

File details

Details for the file hot_notebook_patching-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for hot_notebook_patching-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 50d8238fcab21985a733ab4af8d81ab72bb18b96a5890aec732e39a948e6167b
MD5 baa4f22c1da03e493d08f10895a496a2
BLAKE2b-256 e8fabb22ca6db27acf74980a66dd161b5d8379150d0c81895c16993500a87544

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