Add jupytext for notebooks#473
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a Jupytext-based workflow for maintaining notebooks as version-controlled py:percent scripts, and adds automated execution of those notebooks in CI to catch regressions.
Changes:
- Add a pytest-based notebook execution harness (
jupytext+nbclient) and a dedicated GitHub Actions job to run it. - Add
notebooks/jupytext.tomlconfiguration and ignore generated.ipynbfiles undernotebooks/. - Convert existing notebooks from
.ipynbto Jupytext percent-format.pyscripts (and remove the committed.ipynbversions).
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
tests/notebooks/test_notebooks.py |
Adds pytest that executes numbered notebook scripts via Jupytext + nbclient. |
notebooks/jupytext.toml |
Configures pairing of .ipynb and py:percent formats. |
notebooks/01_observations.py |
Jupytext percent-format version of notebook 01. |
notebooks/02_rewards.py |
Jupytext percent-format version of notebook 02. |
notebooks/03_metrics.py |
Jupytext percent-format version of notebook 03. |
notebooks/04_training.py |
Jupytext percent-format version of notebook 04. |
notebooks/05_inference.py |
Jupytext percent-format version of notebook 05. |
notebooks/06_architecture.py |
Jupytext percent-format version of notebook 06. |
notebooks/01_observations.ipynb |
Removes committed .ipynb (generated artifact under new workflow). |
notebooks/02_rewards.ipynb |
Removes committed .ipynb (generated artifact under new workflow). |
notebooks/03_metrics.ipynb |
Removes committed .ipynb (generated artifact under new workflow). |
notebooks/04_training.ipynb |
Removes committed .ipynb (generated artifact under new workflow). |
notebooks/06_architecture.ipynb |
Removes committed .ipynb (generated artifact under new workflow). |
notebooks/.gitignore |
Ignores generated .ipynb files in notebooks/. |
.github/workflows/ci.yml |
Adds a dedicated CI job to execute the notebooks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+63
to
+71
| - name: Install pufferlib | ||
| env: | ||
| TMPDIR: ${{ runner.temp }}/build | ||
| PIP_NO_CACHE_DIR: 1 | ||
| run: | | ||
| sudo apt-get update && sudo apt-get install -y build-essential cmake | ||
| python -m pip install -U pip pytest jupytext nbclient ipykernel | ||
| pip install -e . --no-cache-dir | ||
| python setup.py build_ext --inplace --force |
Comment on lines
+12
to
+16
| # Kernel runs headless from notebooks/ (05 loads ../weights/...); repo root on | ||
| # PYTHONPATH so `from notebooks.notebook_utils import ...` resolves. | ||
| os.environ["MPLBACKEND"] = "Agg" | ||
| os.environ["PYTHONPATH"] = os.pathsep.join(p for p in [str(REPO_ROOT), os.environ.get("PYTHONPATH", "")] if p) | ||
|
|
Comment on lines
+702
to
+705
| for i, label in enumerate(ego_labels): | ||
| vals = all_ego[:, i] | ||
| print(f"{label}: mean={vals}") | ||
| axes[0, i].hist(vals, bins=60, edgecolor="black", alpha=0.7, color="steelblue") |
eugenevinitsky
approved these changes
Jun 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.