mirror of
https://github.com/wassname/jsteer.git
synced 2026-08-21 11:16:33 +08:00
Adds this session's evidence: uat_prefitted_4b.py (proves the n1000 lens steers, word>random), calib_c_prefitted.py + calib_persona.py (how the demo Cs were chosen: word knee ~0.5, mean_diff ~1), run_nb.py (nbclient notebook executor, bypasses the broken global nbconvert config). Removes u4_step3_guard.sh / retry.sh; fit.py gains --out for scratch fits to non-canonical paths. Co-Authored-By: Claudypoo <288921227+claudypoo@users.noreply.github.com>
23 lines
718 B
Python
23 lines
718 B
Python
"""Execute a notebook via nbclient (bypasses nbconvert's broken global config). (Claude)
|
|
|
|
uv run python scripts/scratch/run_nb.py nbs/word_steering.ipynb /tmp/out.ipynb
|
|
|
|
Runs with cwd = the notebook's dir so its `sys.path.insert("..")` / `../artifacts`
|
|
relative paths resolve. Writes the executed copy (with outputs) to the out path.
|
|
"""
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import nbformat
|
|
from nbclient import NotebookClient
|
|
|
|
nb_path = Path(sys.argv[1]).resolve()
|
|
out_path = Path(sys.argv[2]).resolve()
|
|
os.chdir(nb_path.parent)
|
|
|
|
nb = nbformat.read(nb_path, as_version=4)
|
|
NotebookClient(nb, timeout=2400, kernel_name="python3").execute()
|
|
nbformat.write(nb, out_path)
|
|
print(f"EXECUTED_OK -> {out_path}")
|