Fix cache preservation and uprating order#491
Conversation
f9f04af to
d188cd0
Compare
|
I validated the updated PR against the specific filesystem-order bug we saw in the household API. What looks good:
So for the specific Modal/GCP CA uprating incident, this appears to accomplish what we need. One remaining core correctness concern: the dependency sorter keys by I reproduced this shape locally: from policyengine_core.parameters import ParameterNode, uprate_parameters
root = ParameterNode(data={
"target": {"values": {"2025-01-01": 100}, "metadata": {"uprating": "middle"}},
"middle": {"values": {"2025-01-01": 100}, "metadata": {"uprating": "base"}},
"base": {"values": {"2025-01-01": 100, "2026-01-01": 110}},
})
root.add_child("baseline", root.clone())
uprate_parameters(root)
print(root.middle("2026-01-01")) # 110
print(root.target("2026-01-01")) # 110
print(root.baseline.middle("2026-01-01")) # 100
print(root.baseline.target("2026-01-01")) # 100If cloned/baseline duplicate-name subtrees are expected to be uprated, I think the graph bookkeeping should key by object identity rather than |
d188cd0 to
d7c8255
Compare
|
Thanks, Anthony - I reproduced this locally and opened follow-up #492 to fix cloned subtree uprating by tracking dependency-sort traversal by object identity. Added the cloned-subtree regression you sketched there as well. |
Summary
set_inputstorage writes, including dispatched subperiod writes, branch-specific writes, and on-disk inputs, acrossapply_reformcache invalidationFixes #484.
Fixes #490.
Testing
uvx ruff format --check policyengine_core/holders/holder.py policyengine_core/holders/helpers.py policyengine_core/simulations/simulation.py policyengine_core/parameters/parameter_node.py policyengine_core/parameters/parameter_scale_bracket.py policyengine_core/parameters/operations/uprate_parameters.py tests/core/test_apply_reform_preserves_user_inputs.py tests/core/test_holder_branch_fallback.py tests/core/parameters/operations/test_uprating.pyuvx ruff check policyengine_core/holders/holder.py policyengine_core/holders/helpers.py policyengine_core/simulations/simulation.py policyengine_core/parameters/parameter_node.py policyengine_core/parameters/parameter_scale_bracket.py policyengine_core/parameters/operations/uprate_parameters.py tests/core/test_apply_reform_preserves_user_inputs.py tests/core/test_holder_branch_fallback.py tests/core/parameters/operations/test_uprating.pyuv run --no-sync pytest tests/core/test_apply_reform_preserves_user_inputs.py tests/core/test_apply_reform_invalidates_cache.py tests/core/test_holders.py tests/core/test_holder_branch_fallback.py tests/core/parameters/operations/test_uprating.py -quv run --no-sync pytest -q(536 passed, 5 skipped, 1 xfailed)