Colab Notebook Runner
Executes a local .ipynb on a Colab runtime through the official google-colab-cli, then downloads
the executed notebook and everything the notebook wrote under /content/outputs.
All commands below are relative to this skill's directory (scripts/colab_nb_run.py).
On macOS/Linux the CLI runs natively; on Windows the script transparently runs it inside WSL.
Workflow
Preflight (first use, or after any auth error)
python scripts/colab_nb_run.py preflight
colab CLI not found → python scripts/colab_nb_run.py setup
has_colaboratory_scope: false or no account → tell the user to run the printed
gcloud_login_command themselves (browser login with the account that holds Colab Pro).
Never attempt the OAuth flow yourself.
Inspect the notebook with --dry-run. Fix or propose fixes for warnings
(drive.mount, files.upload/download, input()), and make sure artifacts are written under
os.environ["COLAB_OUTPUT_DIR"] (= /content/outputs); only that directory is fetched.
python scripts/colab_nb_run.py run train.ipynb --gpu A100 --dry-run
Run (long trainings: run in the background and tail stderr)
python scripts/colab_nb_run.py run train.ipynb --gpu A100 -u data/ -r requirements.txt
--gpu {T4,L4,G4,H100,A100} / --tpu {v5e1,v6e1}; on a 400/412 allocation error retry with --gpu T4.
-u PATH (repeatable): files land in /content/<name>, directories in /content/<dirname>/.
- Default: cell-by-cell, stop at the first error, kernel state kept between cells.
--continue-on-error or --whole (single colab exec, no stop-on-error) change that.
--timeout per cell, default 86400 s. --keep-on-error keeps the VM for debugging.
Report from the final JSON on stdout: status, output_notebook, artifacts, failed_cell
(traceback tail), elapsed_sec. Exit codes: 0 ok, 2 cell error, 3 infra error, 4 preflight failure.
Cleanup: the tool stops its own session in finally. If --keep was used, run
python scripts/colab_nb_run.py stop <session> afterwards. Idle VMs burn compute units.
Rules
- Never stop sessions this tool did not create. Accounts may be shared;
sessions may list
other people's runtimes (shown as [?]). stop only accepts names starting with nb-.
- Do not run
colab repl/console/auth/drivemount from the agent: they need a TTY.
- Recommend disabling sleep on the local machine during long runs (the websocket must stay up).
Output layout
<nb dir>/colab_results/<nb>_<stamp>/ (or --dest)
<nb>_output.ipynb executed notebook, checkpointed after every cell
outputs/ copy of /content/outputs (tar + 100 MB chunks, sha256-verified)
run_summary.json the same JSON printed on stdout
session_log.md CLI session log
Troubleshooting
AttributeError: module 'jupyter_kernel_client' has no attribute 'KernelClient' → the PyPI wheel
got installed; rerun setup (installs from git main).
403 SCOPE_NOT_PERMITTED / keep-alive failure → ADC lacks the colaboratory scope; re-run the
gcloud command from preflight.
- Windows: WSL default distro is used; override with
--distro NAME or COLAB_NB_DISTRO.
1---2name: colab-notebook-runner3description: Run a local Jupyter notebook (.ipynb) on a Google Colab GPU/TPU runtime and bring the executed notebook plus generated artifacts (models, checkpoints, logs, figures) back to the local machine. Use when the user asks to run/train a notebook on Colab, e.g. "코랩에서 돌려줘", "run this notebook on Colab", "학습을 코랩 GPU로 실행하고 결과 가져와". Works on macOS, Linux and Windows (via WSL). Does only this one job.4---56# Colab Notebook Runner78Executes a local `.ipynb` on a Colab runtime through the official `google-colab-cli`, then downloads9the executed notebook and everything the notebook wrote under `/content/outputs`.1011All commands below are relative to this skill's directory (`scripts/colab_nb_run.py`).12On macOS/Linux the CLI runs natively; on Windows the script transparently runs it inside WSL.1314## Workflow15161. **Preflight** (first use, or after any auth error)17 ```18 python scripts/colab_nb_run.py preflight19 ```20 - `colab CLI not found` → `python scripts/colab_nb_run.py setup`21 - `has_colaboratory_scope: false` or no account → tell the user to run the printed22 `gcloud_login_command` themselves (browser login with the account that holds Colab Pro).23 Never attempt the OAuth flow yourself.24252. **Inspect the notebook** with `--dry-run`. Fix or propose fixes for warnings26 (`drive.mount`, `files.upload/download`, `input()`), and make sure artifacts are written under27 `os.environ["COLAB_OUTPUT_DIR"]` (= `/content/outputs`); only that directory is fetched.28 ```29 python scripts/colab_nb_run.py run train.ipynb --gpu A100 --dry-run30 ```31323. **Run** (long trainings: run in the background and tail stderr)33 ```34 python scripts/colab_nb_run.py run train.ipynb --gpu A100 -u data/ -r requirements.txt35 ```36 - `--gpu {T4,L4,G4,H100,A100}` / `--tpu {v5e1,v6e1}`; on a 400/412 allocation error retry with `--gpu T4`.37 - `-u PATH` (repeatable): files land in `/content/<name>`, directories in `/content/<dirname>/`.38 - Default: cell-by-cell, stop at the first error, kernel state kept between cells.39 `--continue-on-error` or `--whole` (single `colab exec`, no stop-on-error) change that.40 - `--timeout` per cell, default 86400 s. `--keep-on-error` keeps the VM for debugging.41424. **Report** from the final JSON on stdout: `status`, `output_notebook`, `artifacts`, `failed_cell`43 (traceback tail), `elapsed_sec`. Exit codes: 0 ok, 2 cell error, 3 infra error, 4 preflight failure.44455. **Cleanup**: the tool stops its own session in `finally`. If `--keep` was used, run46 `python scripts/colab_nb_run.py stop <session>` afterwards. Idle VMs burn compute units.4748## Rules4950- **Never stop sessions this tool did not create.** Accounts may be shared; `sessions` may list51 other people's runtimes (shown as `[?]`). `stop` only accepts names starting with `nb-`.52- Do not run `colab repl/console/auth/drivemount` from the agent: they need a TTY.53- Recommend disabling sleep on the local machine during long runs (the websocket must stay up).5455## Output layout5657```58<nb dir>/colab_results/<nb>_<stamp>/ (or --dest)59 <nb>_output.ipynb executed notebook, checkpointed after every cell60 outputs/ copy of /content/outputs (tar + 100 MB chunks, sha256-verified)61 run_summary.json the same JSON printed on stdout62 session_log.md CLI session log63```6465## Troubleshooting6667- `AttributeError: module 'jupyter_kernel_client' has no attribute 'KernelClient'` → the PyPI wheel68 got installed; rerun `setup` (installs from git main).69- `403 SCOPE_NOT_PERMITTED` / keep-alive failure → ADC lacks the `colaboratory` scope; re-run the70 gcloud command from `preflight`.71- Windows: WSL default distro is used; override with `--distro NAME` or `COLAB_NB_DISTRO`.