Skip to content

Refactor the outputs updater, and let it take notebook paths and flags - #1809

Open
classiqdor wants to merge 11 commits into
mainfrom
improve-updater
Open

classiqdor wants to merge 11 commits into
mainfrom
improve-updater

Conversation

@classiqdor

Copy link
Copy Markdown
Contributor

The outputs updater (.internal/update_outputs) is split into functions, takes arguments, and can run on just the notebooks you pass it.

Usage (see main.sh --help)

  • main.sh <notebooks / folders>, or pipe them in: git diff --name-only --relative main | main.sh -
  • every step and option has a flag (--mode, -j, --[no-]links-only, --[no-]create-pr, ...). the UPDATER_* env-vars still work, and the flags take precedence
  • --no-create-branch --no-update-pip --no-create-pr updates the notebooks locally, without git / pip
  • all the invalid arguments are reported at once, before touching git / pip

Layout

  • main.sh (update_notebooks.sh) and update_single_notebook.sh - the scripts you run
  • utils/ - bash helpers (common / git / jupyter / python)
  • patch_notebook/ - the python scripts that edit notebooks (injected_cells.py, update_links.py, notebook_utils.py)

Fixes

  • the venv check never failed
  • >/dev/stdout truncated the logs when redirected to a file
  • a failing notebook doesn't stop the run, and the failed notebooks are listed at the end
  • ctrl-c doesn't leave temporary copies or injected cells behind
  • no PR is opened if the commit failed
  • links-only writes notebooks like nbformat does, so only the links change
  • silence the kernel's "running over TCP without encryption" warning

Tested with a full run against a dummy remote, a fresh venv and a stub gh (pull, pip, 2 notebooks, pre-commit, commit, PR), once links-only and once updating all the outputs.

🤖 Generated with Claude Code

classiqdor and others added 11 commits November 19, 2026 17:55
- split the scripts into functions, and move helpers into utils/ and patch_notebook/
- validate venv and mode before touching git / pip
- fix the venv check, which never failed
- fix `>/dev/stdout` truncating logs that are redirected to a file
- list the notebooks that failed at the end of the run
- fix `update_links.py --force` crashing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t / silence_if

- split utils into common / git / python / jupyter helpers
- add as_bool, silence_if and time_it, and normalize the env-vars once at the top
- drop the `cd` before nbconvert, which already runs the kernel in the notebook's folder
- stop if creating the branch fails, rather than updating on top of a wrong base

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- every env-var has a matching argument, which takes precedence
- boolean flags accept `--flag`, `--no-flag`, and `--flag=<bool>`
- report all the invalid arguments at once, before touching git / pip

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…steps

- paths (notebooks / folders, relative to the current folder) take precedence over --folder / --mode
- '-' reads the paths from stdin, e.g. `git diff --name-only main | main.sh -`
- skip jupyter's .ipynb_checkpoints, non-notebook files, and duplicates
- add --[no-]create-branch, --[no-]update-pip, and --[no-]create-pr
- pass the notebooks NUL-separated, and git add / restore by pathspec

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
update_links.py now writes notebooks like nbformat does too (unescaped unicode and a trailing newline), so that a links-only update changes only the links

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- replace fake_browser.sh with `BROWSER=true`
- drop `update_links.py --force`, and always check the cells of the links
- convert --folder / --mode into paths, so that the notebooks are listed by one code path
- inline the one-line git wrappers, and rename `commit_by_name` to `commit_files`

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- remove the temporary copy / injected cells on exit, even if interrupted (e.g. by ctrl-c)
- don't open a PR if the commit failed
- check the python3 kernel up front, together with the other validations
- fail on a missing notebook in update_single_notebook.sh

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- errors start with "Error:", and are printed to stderr
- the venv and kernel errors say how to fix them
- update_single_notebook.sh reports failures with "[!]", and logs the notebook path as it was given

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- paths already cover --folder, relative to the current folder. UPDATER_FOLDER stays, relative to the repo root
- --mode, as an argument, takes precedence over UPDATER_FOLDER
- the `git diff` example uses --relative, so that it works from any folder

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
checking it before pip made the updater refuse to run in a fresh venv

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant