Skip to content

Modularize agentic ecal - #1

Merged
cfortuna merged 5 commits into
mainfrom
modularize-agentic-ecal
Sep 17, 2026
Merged

cfortuna merged 5 commits into
mainfrom
modularize-agentic-ecal

Conversation

@vh2001

@vh2001 vh2001 commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

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/

  • The model split by concern: descriptors, rates, calib, components, workflow,
    registries, builders, validation, cli.
  • Public API re-exported unchanged, so import agentic_ecal_pkg as ae is a drop-in for the old
    import agentic_ecal as ae.
  • Google-style (Napoleon) docstrings throughout, ready for Sphinx autodoc.
  • agentic-ecal console script + python -m agentic_ecal_pkg (with --json), byte-identical to
    the original module's demo output.

Tests — tests/

  • pytest golden-master / parity suite (~2957 parametrized cases) covering every public function,
    registry, workflow builder, and the full Workflow.run() breakdown.
  • test_paper_numbers.py pins the manuscript's anchors and case-study figures.
  • The original model is frozen as tests/agentic_ecal_reference.py (the golden master).

Layout

  • Everything flattened to the repo root; scripts/clean/ removed.
  • Figure/analysis scripts moved to figure_scripts/ (repointed at the package, output paths fixed).
  • Added examples/ (basic call, case study, custom workflow) and pyproject.toml ([dev] extra
    with pytest, pytest config).

CI

  • .github/workflows/tests.yml runs 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; .gitignore and
    README.md updated accordingly.

Verification

  • pytest — all ~2957 tests pass (package == frozen reference, bit-exact).
  • python -m agentic_ecal_pkg reproduces the original demo output exactly.
  • All examples run; all figure scripts regenerate their figures.
  • Case study reproduces the paper: 4990 prefill / 1020 decode tokens, 5240.26 J, 0.3022 J/bit.

Notes / follow-ups

  • results/ is intentionally untracked — measured CSVs must be provided separately for the
    measured/placement figures (see README).
  • The docstrings are Napoleon-ready but no docs/ scaffold is included yet; can add one on request.

vh2001 and others added 3 commits September 16, 2026 11:18
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>
@vh2001 vh2001 reopened this Sep 16, 2026
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>
@vh2001
vh2001 requested a review from cfortuna September 16, 2026 12:09
@vh2001 vh2001 assigned vh2001 and cfortuna and unassigned vh2001 Sep 16, 2026
@cfortuna
cfortuna merged commit 4e842bb into main Sep 17, 2026
5 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