Modularize agentic ecal - #1
Merged
Merged
Conversation
Refactor the single-file scripts/clean/agentic_ecal.py into agentic_ecal_pkg/, a behaviour-preserving, stdlib-only package split by concern (descriptors, rates, calib, components, workflow, registries, builders, validation, cli). The public API is re-exported unchanged, so `import agentic_ecal_pkg as ae` is a drop-in, and all numbers are bit-for-bit identical to the original. - Freeze the original model as tests/agentic_ecal_reference.py and add a pytest golden-master suite (~2957 parametrized cases) that asserts the package reproduces it exactly, plus test_paper_numbers.py pinning the manuscript's anchors and case-study figures. - Flatten everything to the repo root and remove scripts/clean: move the figure scripts to figure_scripts/ (repointed at the package, output paths fixed) and add examples/ and a pyproject.toml (agentic-ecal CLI, [dev] extra, pytest). - Convert package docstrings to Google-style (Napoleon) for Sphinx. - Add a GitHub Actions workflow running the suite on Python 3.9-3.13. - Stop tracking results/ (measured data provided separately); update README and .gitignore accordingly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The !README.md un-ignore rule matched README.md at any depth, pulling the READMEs from the (otherwise ignored) experimental_results/, experiments_fig12/ and experiments_qwen3_8_27B/ data directories into the previous commit. Anchor the exception to the repo root (!/README.md) and untrack those files. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
List the experiment data directories as folder ignores and remove the now-unnecessary *.md rule (and its !/README.md exception) -- README.md is the only markdown left at the root and is tracked directly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
uv refuses to install into its managed Python with --system (externally managed). Create a venv with uv, install the package + [dev] extra into it, and run pytest from that venv. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
setup-uv (with python-version) already leaves a .venv, so an explicit `uv venv` failed with 'already exists'. Replace the venv+install+run steps with a single `uv run --extra dev python -m pytest`, which reuses or creates the environment and installs the package plus the dev extra. Verified locally against both a pre-existing and a fresh .venv. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
Refactors the single-file energy model (
scripts/clean/agentic_ecal.py) into a clean,modular, installable package at the repo root, without changing any numbers. The refactor is
proven behaviour-preserving by a golden-master test suite that runs the original model and the new
package side by side and asserts bit-for-bit identical results. Also flattens the project layout,
adds examples, Sphinx-ready docstrings, and CI.
What changed
New package —
agentic_ecal_pkg/descriptors,rates,calib,components,workflow,registries,builders,validation,cli.import agentic_ecal_pkg as aeis a drop-in for the oldimport agentic_ecal as ae.agentic-ecalconsole script +python -m agentic_ecal_pkg(with--json), byte-identical tothe original module's demo output.
Tests —
tests/registry, workflow builder, and the full
Workflow.run()breakdown.test_paper_numbers.pypins the manuscript's anchors and case-study figures.tests/agentic_ecal_reference.py(the golden master).Layout
scripts/clean/removed.figure_scripts/(repointed at the package, output paths fixed).examples/(basic call, case study, custom workflow) andpyproject.toml([dev]extrawith pytest, pytest config).
CI
.github/workflows/tests.ymlruns the suite on push/PR across Python 3.9–3.13.Housekeeping
results/and the experiment directories (experimental_results/,experiments_fig12/,experiments_qwen3_8_27B/,experiments_qwen35_9B/) are no longer tracked;.gitignoreandREADME.mdupdated accordingly.Verification
pytest— all ~2957 tests pass (package == frozen reference, bit-exact).python -m agentic_ecal_pkgreproduces the original demo output exactly.Notes / follow-ups
results/is intentionally untracked — measured CSVs must be provided separately for themeasured/placement figures (see README).
docs/scaffold is included yet; can add one on request.