BUG: write MonteCarlo input and output rows atomically (#1110) - #1125
Conversation
|
what is the impact in the final simulation time? |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1125 +/- ##
===========================================
+ Coverage 84.39% 84.42% +0.03%
===========================================
Files 130 130
Lines 17281 17291 +10
===========================================
+ Hits 14584 14598 +14
+ Misses 2697 2693 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
no effect on each flight's simulated t_final. Wall-clock time only adds one os.path.getsize per sim on the happy path. I didnt change the physics and the ODE, and the truncate only runs on write failure. |
|
Lint CI failure was not a Pylint config/fatal problem. Pylint exit code `4` is the warning bitflag (score can still print `10.00/10` with `fail-under=10`). From the job log the PR-introduced warning was: ``` Fixed by rewriting the mock as `def failing_output_open(*args, **kwargs)` so it no longer puts a keyword arg before `*args`. Pushed in a follow-up commit on this branch. (The `I0021` useless-suppression notes on `motor.py` / `sensor.py` are pre-existing on develop and did not set this exit code.) |
|
The direct output-open failure covered by this PR passes on head I also exercised writes that append four bytes and then raise, which exposes two remaining inconsistent states:
The output-side case rolls the input file back but leaves the partially written output row. The input-side case is outside the current The smallest complete form I can see is to record both original sizes, wrap both appends in one exception boundary, and truncate both files back to those sizes after any open/write/flush failure. If rollback itself fails, preserving or chaining the original write exception would keep the initiating failure visible. Tests for partial input, partial output, and rollback failure would cover those paths. I have not opened a replacement PR or changed this branch. Environment: Python 3.12.6; pytest 9.1.1; macOS 26.5.2 arm64. Current |
|
Answering my own question about simulation time: the added cost is one I also checked the thing that worried me more about a rollback-by-truncation approach: whether two parallel producers could interleave a Good to merge. |
b9ad9b5 to
88bbbd3
Compare
Pull request type
Checklist
black rocketpy/ tests//make lint) has passed locallypytest tests -m slow --runslow) have passed locallyCHANGELOG.md— no action needed; an LLM workflow auto-updates it after mergeCurrent behavior
MonteCarlo appends inputs then outputs in two separate
open(..., "a")blocks (serial and parallel). If the second write fails, the inputs file keeps an orphan row and the files no longer line up by index.Fixes #1110
New behavior
_append_simulation_recordrecords the inputs file size, writes inputs then outputs, and truncates inputs back on outputs failure so either both rows land or neither does. Serial and parallel paths both use the helper.Breaking change
Additional information
Focused unit test mocks a failing outputs append and asserts the inputs file was rolled back. Full slow suite not run in this contribution pass.