From 9502b177bf5b090d810af46b463678ae9f0dda4c Mon Sep 17 00:00:00 2001 From: Zakir Jiwani <108548454+JiwaniZakir@users.noreply.github.com> Date: Wed, 1 Apr 2026 23:07:28 +0000 Subject: [PATCH] Regenerate only changed colab notebooks in CI and make Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/check-colab-notebooks.yml | 18 +++++++++++++----- Makefile | 4 ++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check-colab-notebooks.yml b/.github/workflows/check-colab-notebooks.yml index 5d3a06af1..dcda2ce2b 100644 --- a/.github/workflows/check-colab-notebooks.yml +++ b/.github/workflows/check-colab-notebooks.yml @@ -30,18 +30,26 @@ jobs: - name: Install dependencies run: uv sync --all-packages --group notebooks --group docs + - name: Get changed notebook sources + id: changed + run: | + FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha || 'HEAD~1' }} -- docs/notebook_source/*.py | xargs -I{} basename {} || true) + echo "files=$FILES" >> "$GITHUB_OUTPUT" + - name: Generate Colab notebooks run: | - make generate-colab-notebooks + if [ -n "${{ steps.changed.outputs.files }}" ]; then + make generate-colab-notebooks FILES="${{ steps.changed.outputs.files }}" + else + make generate-colab-notebooks + fi - name: Check for differences run: | - # Get the diff, filtering out cell ID changes (which are randomly generated) - # Filter out: file markers (--- and +++), and "id" lines - MEANINGFUL_DIFF=$(git diff docs/colab_notebooks/ | grep -E '^[+-]' | grep -v '^---' | grep -v '^+++' | grep -vE '^[+-]\s*"id": "[0-9a-fA-F]+",?$' || true) + MEANINGFUL_DIFF=$(git diff docs/colab_notebooks/ || true) if [ -z "$MEANINGFUL_DIFF" ]; then - echo "✅ Colab notebooks are up-to-date (ignoring cell ID changes)" + echo "✅ Colab notebooks are up-to-date" else echo "❌ Colab notebooks are out of sync with source files" echo "" diff --git a/Makefile b/Makefile index c4b867981..062ecfc9f 100644 --- a/Makefile +++ b/Makefile @@ -478,7 +478,11 @@ endif generate-colab-notebooks: @echo "📓 Generating Colab-compatible notebooks..." +ifdef FILES + uv run --group docs python docs/scripts/generate_colab_notebooks.py --files $(FILES) +else uv run --group docs python docs/scripts/generate_colab_notebooks.py +endif @echo "✅ Colab notebooks created in docs/colab_notebooks/" # ==============================================================================