Repository navigation
fix: respect DataRecorder start_time when a run ends - #4041
Conversation
|
Performance benchmarks:
|
AshNicolus
left a comment
There was a problem hiding this comment.
Checked this out and ran it against main. The issue repro goes from [2.0] to [], runs ending at or after start_time are unchanged, and 10 of the new cases fail on main while the controls pass. Full suite passes here too. LGTM.
One thing I noticed while testing, not caused by this PR: the end side of the window behaves differently. With interval=5, end_time=20, a run ending at 12 records a final row at 12. With end_time=13 it doesn't, even though 12 is inside the window, because update_next_collection disables the dataset at time 10 once the next collection (15) would pass end_time. Not sure if that is intended. Happy to open a separate issue if it isn't.
|
thanks for testing this against main and for the review. i'll look into the end_time case and open a separate issue for it. |
DatasetConfig.window_size is documented as the maximum number of snapshots to keep. DataRecorder applies it, but JSONDataRecorder kept every snapshot, so memory grew without bound and save_to_json wrote the full history. Adapted for 3.5.x: 3.5 recorders do not record when a run ends (mesa#4041 is 4.0-only), so after run_for(4) the window holds times 2.0 and 3.0; DataRecorder gives the same. The test's expected values are changed accordingly. (cherry picked from commit 668c892) Assisted-by: Claude Opus 5.5
- DataRecorder: an overwrite only replaces the last block if it holds the same time. When a run ended with an empty agent snapshot, which stores no block, the next run's overwrite removed the previous time's data instead. - JSONDataRecorder: a snapshot taken without agents no longer adds a row with value=[] and NaN ids. - JSON, Parquet and SQL recorders return an empty frame with a time column when nothing has been recorded, as DataRecorder does. The scenario runner rejects a frame without columns as a failed outcome. Part of #4165. Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Jan Kwakkel <[email protected]> Adapted for 3.5.x: 3.5 recorders do not record when a run ends (#4041 is 4.0-only), so an overwrite of the last block never happens and the DataRecorder part is dropped, with its test and the test_run_ended test that main has next to it. The JSONDataRecorder empty-snapshot fix and the empty frame with a time column for the JSON, Parquet and SQL recorders are taken unchanged. (cherry picked from commit be399e6) Assisted-by: Claude Opus 5.5
Pre-PR Checklist
Summary
Skip the final recorder snapshot when a run ends before start_time.
Bug / Issue
Fixes #4038. The normal collection path waits for start_time, but RUN_ENDED could still record an early row.
Implementation
Add the missing start_time check in _on_run_ended. Final snapshots at or after start_time still work, including between collection intervals.
Testing
Additional Notes
AI assistance was used to prepare the change and run the tests.
@quaquel ready for review