Derive US program-statistics entity from variable metadata#342
Open
vahid-ahmadi wants to merge 2 commits intomainfrom
Open
Derive US program-statistics entity from variable metadata#342vahid-ahmadi wants to merge 2 commits intomainfrom
vahid-ahmadi wants to merge 2 commits intomainfrom
Conversation
Replace the duplicated entity field in the ``US_PROGRAMS`` dict with a metadata-driven lookup via ``model_version.get_variable(name).entity``, so the program list cannot silently drift when policyengine-us moves a variable between entities. The "missing outputs" check from #327 is preserved. Refs #326. Closes #334 (smaller follow-up on top of merged #327). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
…tadata Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Refs #326. Smaller follow-up on top of merged #327. Replaces #334.
Summary
entityfield fromUS_PROGRAMS. Entity is now derived frommodel_version.get_variable(name).entityat runtime, so the program list cannot silently drift whenpolicyengine-usmoves a variable between entities._validate_program_statistics_config(variable must be both defined in the model and materialized in the simulation outputs).test_us_programs_entities_match_model_metadataso a typo or rename inUS_PROGRAMSis caught at test time, not at simulation time.Why this instead of #334
#334 was authored before #327 landed and (a) is severely behind
main, (b) drops the materialized-outputs check from #327, and (c) introduced aprograms.pymodule /ProgramSpecdataclasses that aren't load-bearing for the entity-derivation goal. This PR keeps only the durable improvement and stays minimal.Test plan
pytest tests/test_us_program_statistics.py(covers entity derivation ineconomic_impact_analysisand the new metadata-match test).pytest tests/test_aggregate.py tests/test_change_aggregate.pystill passes.🤖 Generated with Claude Code