Skip to content

fix: make all templates runnable; clean CLI output; add smoke + sanity tests#5

Merged
AdishAssain merged 1 commit into
mainfrom
fix/templates-cli-and-tests
May 26, 2026
Merged

fix: make all templates runnable; clean CLI output; add smoke + sanity tests#5
AdishAssain merged 1 commit into
mainfrom
fix/templates-cli-and-tests

Conversation

@AdishAssain

Copy link
Copy Markdown
Member

A hands-on UAT (scaffold → configure → run a 10-patch waning-immunity model) surfaced several issues. This fixes them and adds tests that would have caught each.

Bugs fixed

  • init --template {sis,seir} + run was broken. The scaffold shipped one fixed S,I,R seed file, which mismatches SIS (S,I) and SEIR (S,E,I,R) compartments. init now generates a seed file matching the chosen template. (The getting-started walkthrough tells users to init --template seir then run — previously that errored.)
  • run --json reported a non-existent plot path. It returned patch_timeseries_<model>_ode.png while viz saved all_patches_<model>_ode.png. viz now saves the reported name and plots the model's actual compartments (fixes an SIS KeyError: R_0 and SEIR dropping E).
  • Noisy CLI output. list-models / validate / run routed user-facing text through the logger (timestamps + cli.py:NN). Now printed cleanly, matching the docs. --json output is unaffected.
  • Dangling catalog entry. list-models advertised ka_fmd_sirsv_discrete, whose implementation file was removed. Dropped from the catalog.
  • Column case. setup_simulation hardcoded Population; the docs say lowercase population. Now accepted case-insensitively.

Tests added

  • tests/test_cli_e2e.py — every template scaffolds, runs, and the reported CSV/plot artifacts exist on disk; list-models output is clean and only lists implemented models.
  • tests/test_simulation_sanity.py — multi-patch SIRS: population conservation, non-negativity, epidemic growth from a seed, network-driven spatial spread, and endemic persistence under waning immunity.

All 33 tests pass; ruff check and ruff format --check clean.

UAT surfaced several issues; this fixes them and adds empirical smoke +
simulation sanity tests to lock the behaviour.

- init: generate a seed file matching each template's compartments so
  `init --template {sis,seir}` + `run` works (previously the static S,I,R
  seed broke SIS and SEIR with a compartment mismatch)
- run: viz now saves `patch_timeseries_<model>_ode.png` (the path run --json
  reports) and plots the model's actual compartments instead of hardcoded
  S,I,R (fixed SIS KeyError, SEIR missing E)
- list-models: print clean user-facing output instead of routing it through
  the logger (no more timestamps / cli.py source refs); also for run/validate
- catalog: drop the dangling `ka_fmd_sirsv_discrete` entry (model file removed)
- setup_simulation: accept `patch`/`population` columns case-insensitively
- tests: add tests/test_cli_e2e.py (all templates init->run, artifacts exist,
  clean list-models) and tests/test_simulation_sanity.py (conservation,
  non-negativity, epidemic growth, network spread, waning endemicity)
@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@AdishAssain, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 5 minutes and 21 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

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.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2024f289-484e-4ec4-b40d-f4582a234f9a

📥 Commits

Reviewing files that changed from the base of the PR and between c82fe49 and 122b922.

📒 Files selected for processing (7)
  • src/patchsim/cli.py
  • src/patchsim/core/model_runner.py
  • src/patchsim/core/simulation.py
  • src/patchsim/utils/viz.py
  • tests/test_cli_e2e.py
  • tests/test_simulation_sanity.py
  • tests/test_smoke.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/templates-cli-and-tests

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 and usage tips.

@AdishAssain AdishAssain merged commit cae3f3e into main May 26, 2026
3 checks passed
@AdishAssain AdishAssain deleted the fix/templates-cli-and-tests branch May 26, 2026 15:09
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