Skip to content

Fix: simulation result does not get saved#166

Draft
Dhiyaahaq33 wants to merge 1 commit into
cunarist:mainfrom
Dhiyaahaq33:fix-simulation-virtual-state-not-saved
Draft

Fix: simulation result does not get saved#166
Dhiyaahaq33 wants to merge 1 commit into
cunarist:mainfrom
Dhiyaahaq33:fix-simulation-virtual-state-not-saved

Conversation

@Dhiyaahaq33

Copy link
Copy Markdown

Summary

  • SimulationCalculator._save_calculation_results wrote 4 of the 5 state pickles (asset_record, unrealized_changes, scribbles, account_state) but never virtual_state.pickle, despite a comment claiming this was intentional.
  • _load_or_create_previous_state unconditionally tries to read all 5 pickle files inside a single try block. Since virtual_state.pickle never existed, every load raised FileNotFoundError, which was caught and treated as "no previous state" — discarding the other 4 correctly-saved pieces of state too and resetting calculate_from back to the start of the year.
  • Net effect: simulation progress never actually persisted across runs, matching the report in Simulation result does not get saved #146.
  • Fix: virtual_state is now threaded through CalculationResult / _merge_calculation_results and written to disk in _save_calculation_results, restoring parity with _load_or_create_previous_state's expectations (and with the pre-refactor implementation, which did save it).

Fixes #146

Test plan

  • ruff check package/solie/logic/simulation_calculator.py passes
  • python -m py_compile on the changed file passes
  • Manual verification in the running app: run a simulation, close and reopen the year/strategy tab (or restart the app), confirm the calculation resumes from where it left off instead of recalculating from the start of the year — happy to do this if a maintainer can point me at the quickest way to set up a data folder for testing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WJ386AEgV8Z796N4TSJtPn

_save_calculation_results wrote asset_record, unrealized_changes,
scribbles, and account_state, but never virtual_state.pickle, despite
a comment claiming it was intentionally skipped. _load_or_create_previous_state
unconditionally tries to read all five pickle files inside one try
block, so the missing virtual_state file raised FileNotFoundError on
every subsequent run, which discarded the other four successfully-saved
pieces of state too and reset the calculation to start from scratch.

Fixes cunarist#146

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJ386AEgV8Z796N4TSJtPn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simulation result does not get saved

1 participant