Repair tutorials to running order and fix documentation drift#96
Conversation
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 `` 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>
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
Warning Review limit reached
Next review available in: 55 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe 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. ChangesRelease and validation updates
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
sbiandbayesflowexporters to avoid emittingINT64_MAXslice “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.1to 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.
| config.addinivalue_line( | ||
| "markers", | ||
| "notebooks: mark test as a notebook test (skipped unless --run-notebooks is passed)", | ||
| ) |
| 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 |
| 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
tests/test_notebooks.py (1)
32-36: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winGuard against an empty notebook discovery list.
BASIC_NOTEBOOKSis populated by a glob at import time. Ifdocs/basic_tutorialis 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
📒 Files selected for processing (20)
.github/workflows/run_tests.ymlCLAUDE.mdREADME.mddocs/basic_tutorial/basic_tutorial_cpn_torch.ipynbdocs/basic_tutorial/basic_tutorial_lan_jax.ipynbdocs/basic_tutorial/basic_tutorial_lan_torch.ipynbdocs/basic_tutorial/basic_tutorial_opn_torch.ipynbdocs/index.mddocs/overrides/main.htmldocs/tutorials/exporting_sbi_to_onnx.ipynbdocs/using_huggingface.mdnotebooks/exporting_sbi_to_onnx.pypyproject.tomlsrc/lanfactory/__init__.pysrc/lanfactory/onnx/bayesflow.pysrc/lanfactory/onnx/sbi.pytests/conftest.pytests/test_bayesflow_nle_export.pytests/test_notebooks.pytests/test_sbi_nle_export.py
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
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>
| "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" |
| # 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) |
There was a problem hiding this comment.
why did this need to change? Are there dimensions after self.theta_dim + self.x_dim?
There was a problem hiding this comment.
No dims after theta_dim + x_dim — combined 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>
| 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())) |
| [ | ||
| sys.executable, | ||
| "-m", | ||
| "jupyter", | ||
| "nbconvert", | ||
| "--to", | ||
| "notebook", | ||
| "--execute", | ||
| "--stdout", | ||
| f"--ExecutePreprocessor.timeout={NOTEBOOK_TIMEOUT}", | ||
| str(notebook_path.resolve()), | ||
| ] |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
docs/basic_tutorial/basic_tutorial_lan_torch.ipynb (1)
449-449: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove leftover commented-out
train_modelcall.
# 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
📒 Files selected for processing (12)
.github/workflows/run_tests.ymlREADME.mddocs/basic_tutorial/basic_tutorial_cpn_torch.ipynbdocs/basic_tutorial/basic_tutorial_lan_jax.ipynbdocs/basic_tutorial/basic_tutorial_lan_torch.ipynbdocs/basic_tutorial/basic_tutorial_opn_torch.ipynbdocs/index.mdtests/_onnx_utils.pytests/conftest.pytests/test_bayesflow_nle_export.pytests/test_notebooks.pytests/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
| 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()]}" | ||
| ) |
| @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:]}") | ||
|
|
| @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:]}") |
| 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>
| "nbconvert", | ||
| "--to", | ||
| "notebook", | ||
| "--execute", | ||
| "--stdout", | ||
| f"--ExecutePreprocessor.timeout={NOTEBOOK_TIMEOUT}", | ||
| str(notebook_path.resolve()), | ||
| ] |
| 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>
| 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()]}" | ||
| ) |
| 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>
6d8bab1 to
e2ac2cf
Compare
| 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()]}" | ||
| ) |
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)
ssms.config.get_default_generator_config(nestedpipeline/simulator/training/outputsections) +TrainingDataGenerator(config=...);generate_data_training(not_uniform);train_and_evaluate(mlflow_on=...)(notwandb_on). Made self-contained: small in-notebook sims,num_workers=0(ssms forces thespawnstart method), per-notebook output folders.Documentation (18 findings, each adversarially verified)
index.md: rewrote the quick-start walkthrough to the current API; fixed the pip-install andtransform-onnxCLI forms; removed a dead image link;torch (or keras)→PyTorch (or JAX/Flax).README.md: tutorial links,--networks-path-base, the--output-onnx-filetypo + missing backslash, and the "6 arguments" wording.CLAUDE.md: documented all three ONNX exporters (LAN/sbi/bayesflow) + the single-trialjax.vmapcontract.using_huggingface.mdand the sbi export tutorial: smaller fixes.CI
tests/test_notebooks.py(nbconvert for the 4 basic tutorials,marimo exportfor the 2 export tutorials, each in a throwaway CWD) + atest_notebooksjob.Verification
🤖 Generated with Claude Code
Summary by CodeRabbit