Follow-up from PR #2.
Problem
In PR #2, _calculate_variable and _calculate_variable_array in cliff_watch/calculator.py were updated to gracefully return a default (0 / []) when the queried variable doesn't exist on the installed PolicyEngine-US release. This was added so cliff-watch can build and run against both pre- and post-#8086 policyengine-us without a lockstep version bump.
The graceful fallback is silent. If a future policyengine-us rename changes, say, medicaid to medicaid_value, cliff-watch would silently zero out Medicaid rather than raising.
Fix
Emit a one-time warnings.warn(f"Variable {name!r} not in installed policyengine-us release; using default") the first time each missing variable is encountered per process.
Keep a module-level set() of already-warned names so each is only logged once even inside the hot loop of series computation.
Suggested location: cliff_watch/calculator.py around the new _variable_exists helper.
Acceptance: a unit test verifies that (a) the first call with a non-existent variable emits a warning, (b) the second call with the same variable does not, (c) a different variable emits its own warning.
Why not raise
Raising would block cliff-watch from running against any version lacking a listed variable. Since we deliberately use this fallback for chip_premium during the rollout window, raising is too aggressive. A visible warning is the right middle ground.
Follow-up from PR #2.
Problem
In PR #2,
_calculate_variableand_calculate_variable_arrayincliff_watch/calculator.pywere updated to gracefully return a default (0 /[]) when the queried variable doesn't exist on the installed PolicyEngine-US release. This was added so cliff-watch can build and run against both pre- and post-#8086 policyengine-us without a lockstep version bump.The graceful fallback is silent. If a future policyengine-us rename changes, say,
medicaidtomedicaid_value, cliff-watch would silently zero out Medicaid rather than raising.Fix
Emit a one-time
warnings.warn(f"Variable {name!r} not in installed policyengine-us release; using default")the first time each missing variable is encountered per process.Keep a module-level
set()of already-warned names so each is only logged once even inside the hot loop of series computation.Suggested location:
cliff_watch/calculator.pyaround the new_variable_existshelper.Acceptance: a unit test verifies that (a) the first call with a non-existent variable emits a warning, (b) the second call with the same variable does not, (c) a different variable emits its own warning.
Why not raise
Raising would block cliff-watch from running against any version lacking a listed variable. Since we deliberately use this fallback for
chip_premiumduring the rollout window, raising is too aggressive. A visible warning is the right middle ground.