nb-run
Run a Jupyter notebook on a remote machine, walk away, and get told when it finishes.
A Claude Code plugin (and a standalone CLI — the script has no dependencies beyond the
Python standard library).
The problem
A heavy notebook runs for hours. Every run wants its own set of environment flags. The
run dies with the ssh session when the laptop sleeps. And when it crashes, you find out
the next time you sit down at the computer.
What it does
- Named profiles instead of flags held in your head:
-p smoke, -p full.
- Detached from ssh. The notebook runs under
nohup on the server; a closed laptop,
a dropped VPN or a lost network do not kill it.
- A pre-flight check that catches what otherwise costs the full three hours: a
misspelled flag the notebook never reads, a missing kernel, a dirty working tree, a
busy GPU, no disk space.
- A notification when it ends — macOS banner with sound, Slack-shaped webhook, or
Telegram. The webhook can be sent by the server itself, so it arrives with the laptop
shut.
- A readable failure. Next to the log it writes
status.json with the return code,
the duration and the place the notebook died — the failing cell, not the last twenty
lines of nbconvert's own stack.
- Run-to-run comparison.
report diffs duration and metrics against the previous
successful run of the same profile.
- Containers are a first-class case. If jupyter lives in a per-user container rather
than on the host, the run is wrapped in
docker exec while the logs still land on the
host, readable without docker.
Install
As a Claude Code plugin:
claude plugin marketplace add ViderStar/nb-run
claude plugin install nb-run@nb-run
Or inside Claude Code: /plugin marketplace add ViderStar/nb-run, then /plugin install.
As a plain CLI — the script is self-contained, copy it anywhere:
curl -O https://raw.githubusercontent.com/ViderStar/nb-run/main/skills/nb-run/scripts/nb_run.py
curl -O https://raw.githubusercontent.com/ViderStar/nb-run/main/skills/nb-run/scripts/notify.py
chmod +x nb_run.py
Requirements: Python 3.8+ and ssh where you run it; jupyter on the machine that
executes the notebook. Nothing to pip install.
Quick start
1. Register the machine once.
nb_run.py servers add gpu --host 10.0.0.5 --user me \
--workdir /home/me/research \
--jupyter /home/me/venv/bin/jupyter \
--default
nb_run.py servers check gpu
--jupyter matters more than it looks: a system jupyter often belongs to a different
Python and lacks the kernel your notebook declares. If jupyter lives in a container, use
--docker CONTAINER instead. Behind a bastion, add --proxy-jump bastion.example.com.
A machine that already has an alias in ~/.ssh/config needs no registration at all —
just pass --remote <alias> --remote-dir <dir>.
2. Describe the runs. Put nb-run.json next to the notebooks (it is searched for
upwards from the notebook, so one file per experiment tree is enough):
{
"remote": { "host": "gpu", "dir": "/home/me/research" },
"notify": ["mac"],
"profiles": {
"smoke": { "description": "cheap check (minutes)",
"env": { "RUN_TUNING": "0", "TRIALS": "2" } },
"full": { "description": "the real run (~3.5 h)",
"env": { "RUN_TUNING": "1", "TRIALS": "40", "EPOCHS": "8" } }
}
}
3. Run it.
nb_run.py check train.ipynb -p full # pre-flight, seconds
nb_run.py run train.ipynb -p full # prints RUN_ID and returns immediately
nb_run.py wait latest --daemon # notify me, do not hold the terminal
nb_run.py report latest # verdict, duration delta, metric delta
Inputs and outputs
Everything the tool reads is plain JSON in three places, and everything it writes is
either a file you can cat or a line on stdout.
| Input | Where | What for |
|---|
servers.json | ~/.config/nb-run/ | machine inventory: address, user, bastion, how to execute there, path to jupyter, default workdir |
nb-run.json | next to the notebooks, committed | default machine and directory, profiles of env flags, notification channels, metric pattern |
notify.env | ~/.config/nb-run/, chmod 600, never committed | webhook URL / Telegram token |
Overrides go left to right: command-line flag → nb-run.json → servers.json.
| Output | Where |
|---|
RUN_ID | stdout, one second after launch |
| run record (JSON) | ~/.local/state/nb-run/runs/<run_id>.json |
| run history | ~/.local/state/nb-run/runs/runs.jsonl |
| execution log | on the server, fetched to logs/<run_id>.log next to the notebook |
| machine-readable status | status.json next to the log: return code, duration, finish time |
| exit code | wait exits 0 on success, 1 on failure — usable in CI |
Paths follow the XDG variables, and NB_RUN_CONFIG_DIR / NB_RUN_STATE_DIR override
them outright.
Commands