Skip to content

Repair tutorials to running order and fix documentation drift#96

Merged
AlexanderFengler merged 9 commits into
mainfrom
repair-and-refine-tutorials
Jul 13, 2026
Merged

Repair tutorials to running order and fix documentation drift#96
AlexanderFengler merged 9 commits into
mainfrom
repair-and-refine-tutorials

Conversation

@AlexanderFengler

@AlexanderFengler AlexanderFengler commented Jul 12, 2026

Copy link
Copy Markdown
Member

Summary

Brings all 6 documentation tutorials back to running order and corrects 18 verified documentation inaccuracies. The 4 basic tutorials broke on ssm-simulators' flat→nested generator-config migration.

Tutorials (all now execute end-to-end)

  • The 4 basic tutorials: migrate to ssms.config.get_default_generator_config (nested pipeline/simulator/training/output sections) + TrainingDataGenerator(config=...); generate_data_training (not _uniform); train_and_evaluate(mlflow_on=...) (not wandb_on). Made self-contained: small in-notebook sims, num_workers=0 (ssms forces the spawn start method), per-notebook output folders.
  • The 2 marimo export tutorials already passed.

Documentation (18 findings, each adversarially verified)

  • index.md: rewrote the quick-start walkthrough to the current API; fixed the pip-install and transform-onnx CLI forms; removed a dead image link; torch (or keras)PyTorch (or JAX/Flax).
  • README.md: tutorial links, --networks-path-base, the --output-onnx-file typo + missing backslash, and the "6 arguments" wording.
  • CLAUDE.md: documented all three ONNX exporters (LAN/sbi/bayesflow) + the single-trial jax.vmap contract.
  • using_huggingface.md and the sbi export tutorial: smaller fixes.

CI

  • Added tests/test_notebooks.py (nbconvert for the 4 basic tutorials, marimo export for the 2 export tutorials, each in a throwaway CWD) + a test_notebooks job.

Verification

  • All 6 tutorials pass via the harness (~47s). Link check: 0 dead links.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added optional execution tests for tutorial notebooks (run when enabled).
    • Added ONNX export regression checks covering INT64 range and observation slicing.
    • Released version 0.8.0.
  • Documentation
    • Updated Quick Start, installation/CLI examples, ONNX export instructions, and Hugging Face guidance.
    • Refreshed basic tutorial notebooks with regenerated outputs.
  • Bug Fixes
    • Corrected ONNX wrapper observation splitting to respect the configured observation size.
  • Tests / CI
    • Updated CI Python matrix to supported versions and added notebook test job.

AlexanderFengler and others added 2 commits July 12, 2026 00:01
Bring all six documentation tutorials back to running order and correct 18
verified doc inaccuracies. The basic tutorials broke on ssm-simulators'
flat->nested generator-config migration.

Basic tutorials (docs/basic_tutorial — all 4 now execute end-to-end)
- Migrate to ssms.config.get_default_generator_config (nested pipeline/
  simulator/training/output sections) and TrainingDataGenerator(config=...).
- generate_data_training (not generate_data_training_uniform);
  train_and_evaluate(mlflow_on=...) (not wandb_on/wandb_project_id).
- Make self-contained: RUN_SIMS=True with small sims + 2 data files;
  num_workers=0 (ssms forces the "spawn" start method, unsafe for DataLoader
  workers in notebooks); per-notebook output folders so parallel runs don't
  collide; import os in the cpn tutorial.

Docs
- index.md: rewrite the quick-start walkthrough to the current API
  (config/data/dataloaders/network/train), fix the pip install commands and
  the transform-onnx CLI form; "torch (or keras)" -> "PyTorch (or JAX/Flax)".
- README.md: fix the basic-tutorial links, --networks-path-base, the
  --output-onnx-file typo + missing backslash, and the "6 arguments" wording.
- CLAUDE.md: document all three ONNX exporters (LAN/sbi/bayesflow) and the
  single-trial + jax.vmap contract.
- using_huggingface.md: correct the model_card auto-extract source.
- exporting_sbi_to_onnx (marimo source, regenerated .ipynb): name the real
  sbi NRE classes instead of "RatioApproximator-style".

CI / gating
- Add tests/test_notebooks.py: nbconvert for the 4 basic tutorials, marimo
  export for the 2 export tutorials, each in a throwaway working directory.
  Gated behind --run-notebooks.
- Add a test_notebooks job to run_tests.yml so tutorials cannot silently drift
  out of sync with the code again.

Verified: all 6 tutorials pass
(uv run pytest tests/test_notebooks.py --run-notebooks) in ~47s.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The rewritten quick-start no longer relies on a pre-rendered plot; remove the
orphaned `![png](basic_tutorial_files/basic_tutorial_22_1.png)` reference (the
image lives at repo-root basic_tutorial_files/, not under docs/, so it was a
dead link in the built site) and its stale matplotlib repr output line.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 12, 2026 04:55
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@AlexanderFengler, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 076d82ee-b519-4607-8fe5-d425ed5edcba

📥 Commits

Reviewing files that changed from the base of the PR and between 6d8bab1 and 4e77050.

📒 Files selected for processing (4)
  • docs/overrides/main.html
  • pyproject.toml
  • src/lanfactory/__init__.py
  • tests/_onnx_utils.py
📝 Walkthrough

Walkthrough

The PR bumps the package to 0.8.0, raises the Python baseline to 3.12, narrows ONNX observation slicing, adds ONNX and notebook validation, refreshes tutorial workflows and outputs, and updates installation, CLI, ONNX, and release documentation.

Changes

Release and validation updates

Layer / File(s) Summary
Release metadata and runtime requirements
pyproject.toml, src/lanfactory/__init__.py, .github/workflows/run_tests.yml, CLAUDE.md, docs/overrides/main.html
Updates version metadata to 0.8.0, raises the supported Python baseline to 3.12, updates the simulator dependency, and aligns CI and release documentation.
ONNX input slicing and regression checks
src/lanfactory/onnx/*, tests/_onnx_utils.py, tests/test_*_nle_export.py
Bounds observation slices by the configured dimension and adds INT64-to-INT32 export checks.
Notebook execution validation
.github/workflows/run_tests.yml, tests/conftest.py, tests/test_notebooks.py, pyproject.toml
Adds opt-in Jupyter and marimo notebook tests and runs them in a dedicated CI job.
Tutorial data and training workflows
docs/basic_tutorial/*.ipynb, docs/index.md
Updates ssms data generation, dataloaders, training options, model configuration examples, and tutorial execution results.
Documentation and CLI alignment
README.md, CLAUDE.md, docs/tutorials/*, docs/using_huggingface.md, notebooks/exporting_sbi_to_onnx.py
Updates installation, training, ONNX export, HSSM consumption, and model-card documentation.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main changes: repairing tutorials and updating outdated documentation.
Docstring Coverage ✅ Passed Docstring coverage is 84.62% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch repair-and-refine-tutorials

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores the project’s end-to-end documentation tutorials after upstream API drift (notably ssm-simulators generator-config changes) and adds CI coverage to prevent future tutorial breakage, while also addressing an ONNX-export slicing regression that could silently corrupt inputs under jax_enable_x64=False.

Changes:

  • Fix ONNX wrapper slicing in sbi and bayesflow exporters to avoid emitting INT64_MAX slice “ends” sentinels, plus regression tests documenting int64/int32 behavior.
  • Add a notebook execution test harness (skipped by default) and a dedicated GitHub Actions job to run all tutorials.
  • Update docs/tutorial notebooks and bump version to 0.7.1 to reflect current APIs and CLI flags.

Reviewed changes

Copilot reviewed 17 out of 20 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/lanfactory/onnx/sbi.py Bound x slice by x_dim to avoid INT64_MAX sentinel in ONNX Slice ops.
src/lanfactory/onnx/bayesflow.py Same bounded-slice fix for bayesflow NLE/NRE wrappers.
tests/test_sbi_nle_export.py Add regression test asserting exported int64 constants stay within int32 range (sbi path).
tests/test_bayesflow_nle_export.py Add strict xfail documenting that bayesflow exports remain non–int32-clean due to internal flow ops.
tests/test_notebooks.py New notebook/tutorial execution tests (nbconvert + marimo export), gated behind --run-notebooks.
tests/conftest.py Add pytest option/collection logic to skip notebook tests unless opted in; register marker.
.github/workflows/run_tests.yml Add test_notebooks job to execute all tutorials in CI using uv.
pyproject.toml Bump version to 0.7.1; add pytest marker declaration.
src/lanfactory/__init__.py Bump __version__ to 0.7.1.
README.md Update tutorial links/CLI flags and fix transform-onnx example typos.
docs/index.md Refresh quick-start walkthrough to current APIs and CLI usage.
docs/using_huggingface.md Update architecture comment to current config pickle naming.
notebooks/exporting_sbi_to_onnx.py Clarify NRE path guidance and naming.
docs/tutorials/exporting_sbi_to_onnx.ipynb Sync exported tutorial content with updated NRE guidance/output.
docs/basic_tutorial/basic_tutorial_lan_jax.ipynb Update tutorial to current generator config + mlflow flag + safer dataloader settings.
docs/overrides/main.html Update release banner to v0.7.1.
CLAUDE.md Document the three ONNX exporters and the single-trial export/vmap batching contract.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/conftest.py Outdated
Comment on lines +59 to +62
config.addinivalue_line(
"markers",
"notebooks: mark test as a notebook test (skipped unless --run-notebooks is passed)",
)
Comment thread tests/test_notebooks.py Outdated
Comment thread README.md Outdated
Comment thread tests/test_sbi_nle_export.py Outdated
Comment on lines +272 to +287
def _max_int64_abs(onnx_model: onnx.ModelProto) -> int:
"""Largest absolute value stored in any int64 tensor in the graph (0 if none)."""
tensors = list(onnx_model.graph.initializer)
for node in onnx_model.graph.node:
for attr in node.attribute:
if attr.type == onnx.AttributeProto.TENSOR:
tensors.append(attr.t)
elif attr.type == onnx.AttributeProto.TENSORS:
tensors.extend(attr.tensors)
biggest = 0
for tensor in tensors:
if tensor.data_type == onnx.TensorProto.INT64:
arr = onnx.numpy_helper.to_array(tensor)
if arr.size:
biggest = max(biggest, int(np.abs(arr).max()))
return biggest
Comment thread tests/test_bayesflow_nle_export.py Outdated
Comment on lines +313 to +328
def _max_int64_abs(onnx_model: onnx.ModelProto) -> int:
"""Largest absolute value stored in any int64 tensor in the graph (0 if none)."""
tensors = list(onnx_model.graph.initializer)
for node in onnx_model.graph.node:
for attr in node.attribute:
if attr.type == onnx.AttributeProto.TENSOR:
tensors.append(attr.t)
elif attr.type == onnx.AttributeProto.TENSORS:
tensors.extend(attr.tensors)
biggest = 0
for tensor in tensors:
if tensor.data_type == onnx.TensorProto.INT64:
arr = onnx.numpy_helper.to_array(tensor)
if arr.size:
biggest = max(biggest, int(np.abs(arr).max()))
return biggest

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/test_notebooks.py (1)

32-36: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Guard against an empty notebook discovery list.

BASIC_NOTEBOOKS is populated by a glob at import time. If docs/basic_tutorial is ever moved/renamed, the glob returns [], pytest parametrizes over an empty set, and the test is silently skipped rather than failing — which quietly defeats this suite's stated goal of preventing tutorial drift. A cheap assertion keeps the safety net honest.

♻️ Proposed guard
 BASIC_NOTEBOOKS = sorted(BASIC_TUTORIAL_DIR.glob("*.ipynb"))
+assert BASIC_NOTEBOOKS, f"No basic-tutorial notebooks found in {BASIC_TUTORIAL_DIR}"
 MARIMO_NOTEBOOKS = [
     MARIMO_DIR / "exporting_sbi_to_onnx.py",
     MARIMO_DIR / "exporting_bayesflow_to_onnx.py",
 ]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_notebooks.py` around lines 32 - 36, Add an import-time assertion
immediately after BASIC_NOTEBOOKS is built to require at least one discovered
notebook, with a clear failure message identifying the expected basic tutorial
directory. Leave MARIMO_NOTEBOOKS and the existing discovery logic unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/run_tests.yml:
- Around line 66-67: Update the actions/checkout@v4 step in the workflow to set
persist-credentials to false, preventing the checkout token from being stored in
the runner’s Git configuration.

In `@tests/test_bayesflow_nle_export.py`:
- Around line 313-328: Extract the duplicated _max_int64_abs helper into a
shared test utility module, then remove its local definitions from
tests/test_bayesflow_nle_export.py and tests/test_sbi_nle_export.py. Import and
reuse the shared helper in both files without changing its behavior.

---

Nitpick comments:
In `@tests/test_notebooks.py`:
- Around line 32-36: Add an import-time assertion immediately after
BASIC_NOTEBOOKS is built to require at least one discovered notebook, with a
clear failure message identifying the expected basic tutorial directory. Leave
MARIMO_NOTEBOOKS and the existing discovery logic unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c08ce04b-1107-4537-a0fc-98deaf3417c6

📥 Commits

Reviewing files that changed from the base of the PR and between 4646598 and 5f6f7b2.

📒 Files selected for processing (20)
  • .github/workflows/run_tests.yml
  • CLAUDE.md
  • README.md
  • docs/basic_tutorial/basic_tutorial_cpn_torch.ipynb
  • docs/basic_tutorial/basic_tutorial_lan_jax.ipynb
  • docs/basic_tutorial/basic_tutorial_lan_torch.ipynb
  • docs/basic_tutorial/basic_tutorial_opn_torch.ipynb
  • docs/index.md
  • docs/overrides/main.html
  • docs/tutorials/exporting_sbi_to_onnx.ipynb
  • docs/using_huggingface.md
  • notebooks/exporting_sbi_to_onnx.py
  • pyproject.toml
  • src/lanfactory/__init__.py
  • src/lanfactory/onnx/bayesflow.py
  • src/lanfactory/onnx/sbi.py
  • tests/conftest.py
  • tests/test_bayesflow_nle_export.py
  • tests/test_notebooks.py
  • tests/test_sbi_nle_export.py

Comment thread .github/workflows/run_tests.yml Outdated
Comment thread tests/test_bayesflow_nle_export.py Outdated
@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This repo's native deps (jax/torch/bayesflow/...) occasionally SIGILL on import
on certain runner CPUs — a transient crash (exit 132) that happens before any
notebook runs (documented in CLAUDE.md). Wrap the notebook run in a small retry
so a fresh re-import rides through it, instead of flaking the gate red.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 12, 2026 05:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 20 changed files in this pull request and generated 4 comments.

Comment thread README.md Outdated
Comment on lines 343 to 345
"text": [
"/Users/afengler/Library/CloudStorage/OneDrive-Personal/proj_lanfactory/LANfactory/.venv/lib/python3.11/site-packages/torch/utils/data/dataloader.py:683: UserWarning: 'pin_memory' argument is set as true but not supported on MPS now, then device pinned memory won't be used.\n",
"/Users/afengler/Projects/proj_hssmspine/HSSMSpine/repos/LANfactory/.venv/lib/python3.12/site-packages/torch/utils/data/dataloader.py:683: UserWarning: 'pin_memory' argument is set as true but not supported on MPS now, then device pinned memory won't be used.\n",
" warnings.warn(warn_msg)\n"
Comment thread docs/index.md Outdated
Comment thread tests/test_notebooks.py Outdated
# combined: rank-1, (theta_dim + x_dim,) — see module docstring.
theta = combined[: self.theta_dim].unsqueeze(0)
x_obs = combined[self.theta_dim :].unsqueeze(0)
x_obs = combined[self.theta_dim : self.theta_dim + self.x_dim].unsqueeze(0)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did this need to change? Are there dimensions after self.theta_dim + self.x_dim?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No dims after theta_dim + x_dimcombined is exactly (theta_dim + x_dim,) (see the forward() docstring), so combined[theta_dim:] and combined[theta_dim : theta_dim + x_dim] return the identical slice. The value is unchanged.

The reason for the explicit bound is the ONNX export, not the slice value: an open-ended [theta_dim:] traces to a Slice op whose ends is torch's INT64_MAX sentinel (9223372036854775807). When HSSM loads the graph with jax_enable_x64=False, that int64 constant is truncated to int32 (→ a bogus negative value), silently corrupting the slice. Bounding to a concrete small integer keeps every exported constant int32-safe — which is exactly what the new test_export_int64_values_fit_in_int32 regression asserts.

- Notebooks: set pin_memory=False in the dataloader factory and trainer across
  all 4 basic tutorials and re-execute, so committed outputs no longer carry the
  MPS `pin_memory` UserWarning that embedded an absolute local filesystem path.
- tests/conftest.py: drop the redundant `notebooks` marker registration; it's
  already declared in `[tool.pytest.ini_options].markers`.
- tests/test_notebooks.py: report the real subprocess timeout (NOTEBOOK_TIMEOUT
  + 60) in the TimeoutExpired message; assert notebook discovery is non-empty so
  a moved/renamed dir fails loudly instead of silently skipping the suite.
- Deduplicate the `_max_int64_abs` ONNX test helper into tests/_onnx_utils.py
  (as `max_int64_abs`), imported by the sbi and bayesflow export tests.
- run_tests.yml: set `persist-credentials: false` on both checkout steps.
- README.md: fix a double period after the tutorial link.
- docs/index.md: "onnx" -> "ONNX".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 12, 2026 13:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 21 changed files in this pull request and generated 2 comments.

Comment thread tests/_onnx_utils.py Outdated
Comment on lines +18 to +21
if tensor.data_type == onnx.TensorProto.INT64:
arr = onnx.numpy_helper.to_array(tensor)
if arr.size:
biggest = max(biggest, int(np.abs(arr).max()))
Comment thread tests/test_notebooks.py
Comment on lines +75 to +86
[
sys.executable,
"-m",
"jupyter",
"nbconvert",
"--to",
"notebook",
"--execute",
"--stdout",
f"--ExecutePreprocessor.timeout={NOTEBOOK_TIMEOUT}",
str(notebook_path.resolve()),
]

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
docs/basic_tutorial/basic_tutorial_lan_torch.ipynb (1)

449-449: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove leftover commented-out train_model call.

# model_trainer.train_model(save_history=True, save_model=True, verbose=0) is newly added dead code in a tutorial this PR is explicitly repairing for API accuracy. Leaving a commented reference to an alternate (possibly stale) method risks confusing readers following the tutorial.

🧹 Proposed cleanup
-    "\n",
-    "# model_trainer.train_model(save_history=True, save_model=True, verbose=0)\n",
     "model_trainer.train_and_evaluate(\n",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/basic_tutorial/basic_tutorial_lan_torch.ipynb` at line 449, Remove the
commented-out model_trainer.train_model call from the tutorial notebook cell,
leaving the surrounding tutorial content unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@docs/basic_tutorial/basic_tutorial_lan_torch.ipynb`:
- Line 449: Remove the commented-out model_trainer.train_model call from the
tutorial notebook cell, leaving the surrounding tutorial content unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 641041a5-9e3c-48d0-9a00-b540ed4e1e02

📥 Commits

Reviewing files that changed from the base of the PR and between 5f6f7b2 and d0b8fd2.

📒 Files selected for processing (12)
  • .github/workflows/run_tests.yml
  • README.md
  • docs/basic_tutorial/basic_tutorial_cpn_torch.ipynb
  • docs/basic_tutorial/basic_tutorial_lan_jax.ipynb
  • docs/basic_tutorial/basic_tutorial_lan_torch.ipynb
  • docs/basic_tutorial/basic_tutorial_opn_torch.ipynb
  • docs/index.md
  • tests/_onnx_utils.py
  • tests/conftest.py
  • tests/test_bayesflow_nle_export.py
  • tests/test_notebooks.py
  • tests/test_sbi_nle_export.py
🚧 Files skipped from review as they are similar to previous changes (7)
  • .github/workflows/run_tests.yml
  • tests/test_notebooks.py
  • README.md
  • docs/index.md
  • docs/basic_tutorial/basic_tutorial_lan_jax.ipynb
  • docs/basic_tutorial/basic_tutorial_cpn_torch.ipynb
  • docs/basic_tutorial/basic_tutorial_opn_torch.ipynb

…orials

# Conflicts:
#	.github/workflows/run_tests.yml
Copilot AI review requested due to automatic review settings July 12, 2026 13:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 21 changed files in this pull request and generated 4 comments.

Comment thread tests/test_notebooks.py
Comment on lines +32 to +45
BASIC_NOTEBOOKS = sorted(BASIC_TUTORIAL_DIR.glob("*.ipynb"))
# Fail loudly if discovery finds nothing (e.g. the dir was moved/renamed) rather
# than parametrizing over an empty set and silently skipping the whole suite.
assert BASIC_NOTEBOOKS, (
f"No basic-tutorial notebooks discovered in {BASIC_TUTORIAL_DIR}"
)
MARIMO_NOTEBOOKS = [
MARIMO_DIR / "exporting_sbi_to_onnx.py",
MARIMO_DIR / "exporting_bayesflow_to_onnx.py",
]
assert all(nb.exists() for nb in MARIMO_NOTEBOOKS), (
f"Missing marimo tutorial source(s): "
f"{[str(nb) for nb in MARIMO_NOTEBOOKS if not nb.exists()]}"
)
Comment thread tests/test_notebooks.py
Comment on lines +68 to +90
@pytest.mark.notebooks
@pytest.mark.parametrize(
"notebook_path", BASIC_NOTEBOOKS, ids=[nb.stem for nb in BASIC_NOTEBOOKS]
)
def test_basic_tutorial_executes(notebook_path: Path):
"""Execute a basic-tutorial Jupyter notebook via nbconvert."""
success, output = _run(
[
sys.executable,
"-m",
"jupyter",
"nbconvert",
"--to",
"notebook",
"--execute",
"--stdout",
f"--ExecutePreprocessor.timeout={NOTEBOOK_TIMEOUT}",
str(notebook_path.resolve()),
]
)
if not success:
pytest.fail(f"{notebook_path.name} failed to execute:\n{output[-4000:]}")

Comment thread tests/test_notebooks.py
Comment on lines +92 to +112
@pytest.mark.notebooks
@pytest.mark.parametrize(
"notebook_path", MARIMO_NOTEBOOKS, ids=[nb.stem for nb in MARIMO_NOTEBOOKS]
)
def test_marimo_tutorial_executes(notebook_path: Path):
"""Execute a marimo export tutorial by exporting it to ipynb (runs the notebook)."""
success, output = _run(
[
sys.executable,
"-m",
"marimo",
"export",
"ipynb",
str(notebook_path.resolve()),
"-o",
"exported.ipynb",
"--include-outputs",
]
)
if not success:
pytest.fail(f"{notebook_path.name} failed to execute:\n{output[-4000:]}")
Comment thread .github/workflows/run_tests.yml Outdated
Comment on lines +94 to +100
run: |
for attempt in 1 2 3; do
echo "Notebook execution attempt ${attempt}/3..."
uv run pytest tests/test_notebooks.py --run-notebooks --no-cov -v && exit 0
echo "Attempt ${attempt} failed (likely the transient native SIGILL-on-import flake); retrying..."
done
exit 1
ssm-simulators 0.13.1 ships portable manylinux wheels (arch-gated -march, not
-march=native), fixing the intermittent SIGILL/exit-132 import crash in CI.
Pin >=0.13.1 so every job installs the fixed wheel, and remove the notebook-job
retry wrapper that worked around the flake.

0.13.x requires Python >=3.12, so drop 3.11 (requires-python, classifier, CI
matrix) to align with ssm-simulators and HSSM (both >=3.12). Previously 3.11
resolved to an old ssm-simulators 0.12.5 — a divergent, still-SIGILL-prone
wheel. Re-locking also prunes two 3.11-only transitive deps (overrides, tomli).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 12, 2026 16:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 21 changed files in this pull request and generated 2 comments.

Comment thread tests/test_notebooks.py
Comment on lines +79 to +86
"nbconvert",
"--to",
"notebook",
"--execute",
"--stdout",
f"--ExecutePreprocessor.timeout={NOTEBOOK_TIMEOUT}",
str(notebook_path.resolve()),
]
Comment thread tests/_onnx_utils.py Outdated
Comment on lines +18 to +21
if tensor.data_type == onnx.TensorProto.INT64:
arr = onnx.numpy_helper.to_array(tensor)
if arr.size:
biggest = max(biggest, int(np.abs(arr).max()))
Pre-existing format drift from the _max_int64_abs de-dup, previously masked
because run_tests SIGILLed at import before reaching the ruff step. With the
ssm-simulators 0.13.1 portable-wheel fix the suite now runs to completion, so
'ruff format --check' finally sees (and now passes) these files.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 12, 2026 16:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 21 changed files in this pull request and generated 1 comment.

Comment thread tests/test_notebooks.py
Comment on lines +32 to +45
BASIC_NOTEBOOKS = sorted(BASIC_TUTORIAL_DIR.glob("*.ipynb"))
# Fail loudly if discovery finds nothing (e.g. the dir was moved/renamed) rather
# than parametrizing over an empty set and silently skipping the whole suite.
assert BASIC_NOTEBOOKS, (
f"No basic-tutorial notebooks discovered in {BASIC_TUTORIAL_DIR}"
)
MARIMO_NOTEBOOKS = [
MARIMO_DIR / "exporting_sbi_to_onnx.py",
MARIMO_DIR / "exporting_bayesflow_to_onnx.py",
]
assert all(nb.exists() for nb in MARIMO_NOTEBOOKS), (
f"Missing marimo tutorial source(s): "
f"{[str(nb) for nb in MARIMO_NOTEBOOKS if not nb.exists()]}"
)
Copilot AI review requested due to automatic review settings July 12, 2026 23:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 21 changed files in this pull request and generated 1 comment.

Comment thread tests/conftest.py
Comment on lines +43 to +50
def pytest_collection_modifyitems(config, items):
"""Skip notebook tests unless --run-notebooks is passed."""
if config.getoption("--run-notebooks"):
return
skip_notebooks = pytest.mark.skip(reason="need --run-notebooks option to run")
for item in items:
if "notebooks" in item.keywords:
item.add_marker(skip_notebooks)
max_int64_abs took np.abs() of int64 arrays, which overflows on INT64_MIN (the
result stays negative), so the helper under-reported the true magnitude and the
int32-range regression test could pass even with an out-of-range INT64_MIN
constant in the graph. Compute the max absolute value in pure Python over the
flattened elements: int() gives arbitrary-precision ints so abs() can't
overflow, and it also handles 0-d (scalar) int64 tensors, which
np.abs(...).max() on an object array does not. Surfaced by the Copilot review.

Bump 0.7.1 -> 0.8.0 (minor): this PR drops Python 3.11 support and raises the
ssm-simulators floor to >=0.13.1 — more than a patch for a 0.x package.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@AlexanderFengler
AlexanderFengler force-pushed the repair-and-refine-tutorials branch from 6d8bab1 to e2ac2cf Compare July 12, 2026 23:40
Copilot AI review requested due to automatic review settings July 12, 2026 23:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 21 changed files in this pull request and generated 1 comment.

Comment thread tests/test_notebooks.py
Comment on lines +32 to +45
BASIC_NOTEBOOKS = sorted(BASIC_TUTORIAL_DIR.glob("*.ipynb"))
# Fail loudly if discovery finds nothing (e.g. the dir was moved/renamed) rather
# than parametrizing over an empty set and silently skipping the whole suite.
assert BASIC_NOTEBOOKS, (
f"No basic-tutorial notebooks discovered in {BASIC_TUTORIAL_DIR}"
)
MARIMO_NOTEBOOKS = [
MARIMO_DIR / "exporting_sbi_to_onnx.py",
MARIMO_DIR / "exporting_bayesflow_to_onnx.py",
]
assert all(nb.exists() for nb in MARIMO_NOTEBOOKS), (
f"Missing marimo tutorial source(s): "
f"{[str(nb) for nb in MARIMO_NOTEBOOKS if not nb.exists()]}"
)
@AlexanderFengler
AlexanderFengler merged commit e5506c2 into main Jul 13, 2026
9 checks passed
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.

2 participants