Skip to content

Consolidate computation_modules with CountryConfig from library#139

Draft
anth-volk wants to merge 2 commits intomainfrom
feat/consolidate-economic-impact
Draft

Consolidate computation_modules with CountryConfig from library#139
anth-volk wants to merge 2 commits intomainfrom
feat/consolidate-economic-impact

Conversation

@anth-volk
Copy link
Contributor

Fixes #138

Summary

  • Replace 6 duplicate UK/US module functions with single config-driven functions (program_statistics, poverty, inequality, budget_summary now unified)
  • Replace two dispatch tables (UK_MODULE_DISPATCH + US_MODULE_DISPATCH) with single MODULE_DISPATCH + get_dispatch_for_country()
  • Use library compute functionscompute_decile_impacts(), compute_budget_summary(), compute_program_statistics() from policyengine instead of inline implementations
  • Remove hardcoded program/variable lists — now owned by US_CONFIG/UK_CONFIG in the library
  • Remove model_rebuild() calls — fixed in library's __init__.py
  • Simplify run_modules() — accepts country_id directly, resolves config + dispatch internally
  • Net reduction: 492 lines removed, 300 added (~190 lines net)

Dependencies

Test plan

  • All 29 computation module tests pass
  • All 114 analysis/registry tests pass (1 DB-related failure is pre-existing)
  • ruff format and ruff check clean
  • Integration test with live database after library is published

🤖 Generated with Claude Code

anth-volk and others added 2 commits March 17, 2026 20:26
…rary

Fixes #138

- Replace 6 duplicate UK/US module functions with single config-driven functions
- Replace UK_MODULE_DISPATCH + US_MODULE_DISPATCH with single MODULE_DISPATCH
- Add get_dispatch_for_country() to filter dispatch by MODULE_REGISTRY
- Use compute_decile_impacts(), compute_budget_summary(), compute_program_statistics()
  from policyengine library instead of inline implementations
- run_modules() now accepts country_id and resolves config + dispatch internally
- Remove model_rebuild() calls (fixed in library __init__.py)
- Remove hardcoded program/variable lists (now in US_CONFIG/UK_CONFIG)
- Update tests to match new single-dispatch architecture (29/29 pass)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Both economy_comparison_uk() and economy_comparison_us() Modal functions
now call run_modules() instead of duplicating all computation logic
inline. This eliminates ~740 lines of duplicate code.

The setup (DB loading, simulation creation, output dataset saving) and
teardown (status marking, error handling) remain in the Modal functions,
but all computation (deciles, programs, poverty, inequality, budget,
geographic impacts) is delegated to the shared module dispatch system.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Consolidate computation_modules.py with CountryConfig from policyengine library

1 participant