Repository navigation
Recalculate an incomplete Stage 12 cache file outside the output-plan check's except block - #1036
Merged
Merged
Conversation
Three tests fail on main: an error from run() or save(), and a KeyboardInterrupt from run(), raised while Stage12CachedSimulation.ensure() recalculates an incomplete cache file carry the output-plan ValueError as __context__. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stage12CachedSimulation.ensure() now only notes in its except block that the loaded file failed the output plan, and runs and saves after the try statement, so a recalculation error or a preemption carries no chained output-plan error. Fixes #1035. Co-Authored-By: Claude Opus 5.5 <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 #1035
Same-Repository Draft PR Check
PolicyEngine/policyengine-sim-api, not a personal fork.Changelog
changelog.d/1035.fixed.md, whose type is fixed.Summary
Stage12CachedSimulation.ensure()recalculated an incomplete Stage 12 cache file inside theexcept (TypeError, ValueError):block of its output-plan check, so any exception fromrun()orsave(), including a Modal preemption'sKeyboardInterrupt, carried the output-planValueErroras__context__. The Public API's telemetry error report fingerprints an error by the first traceback in its stack, so these errors were grouped under the check instead of where they were raised.exceptblock now only logs the same WARNING and notes that the file is incomplete; the recalculation (incompleteoutcome,run(),save(), clearing .py's in-memory cache) runs after thetrystatement.TypeErrororValueErrorfrom the check, which still propagate.Simulation.ensure(), which the cache-miss path here still goes through until the service moves to a .py release with that fix.Merge order: merge after #1033 (policyengine-observability 3.0.7), so the service records preemptions at WARNING before any error's fingerprint changes. Deploys run one at a time in merge order, so merging after #1033 is enough.
Testing
projects/policyengine-simulation-executor/tests/test_stage12_cache_runtime.py, run by node ID:test_recalculation_error_carries_no_output_plan_error[run]and[save]: an error fromrun()orsave()while recalculating an incomplete file is raised unchanged, with__context__and__cause__ofNone, and the outcome isincomplete.test_preemption_during_recalculation_carries_no_output_plan_error: aKeyboardInterruptfromrun()carries no__context__.ValueErroras__context__. Green (with the change): all 3 pass.format --checkandcheckpass on both changed files. Pyright was not run locally; CI runs it.Review
Self-review by the authoring session; findings only, no review disposition.
ensure()againstmain, confirmed the flag can't be unbound, and ran the 3 tests againstmain's module, where all 3 fail. Review stopped after round 1.src/modal/segmented_national.py:381-383respawns an overdue child insideexcept TimeoutError:, so a spawn failure carries the poll'sTimeoutErroras context. Child run errors are not affected.🤖 Generated with Claude Code