Consolidate computation_modules with CountryConfig from library#139
Draft
Consolidate computation_modules with CountryConfig from library#139
Conversation
…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>
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.
Fixes #138
Summary
UK_MODULE_DISPATCH+US_MODULE_DISPATCH) with singleMODULE_DISPATCH+get_dispatch_for_country()compute_decile_impacts(),compute_budget_summary(),compute_program_statistics()from policyengine instead of inline implementationsUS_CONFIG/UK_CONFIGin the librarymodel_rebuild()calls — fixed in library's__init__.pyrun_modules()— acceptscountry_iddirectly, resolves config + dispatch internallyDependencies
Test plan
ruff formatandruff checkclean🤖 Generated with Claude Code