Repository navigation
Record TableDataSet rows once in data recorders - #3969
Closed
0xnithinmys wants to merge 3 commits into
Closed
0xnithinmys wants to merge 3 commits into
0xnithinmys wants to merge 3 commits into
Conversation
TableDataSet.data returns its live list of rows, and every recorder stored that whole list at each snapshot. Each row was repeated once per snapshot and stamped with times before it was added. BaseDataRecorder now passes only the rows added since the previous snapshot of a TableDataSet; an overwrite passes the rows since the start of the snapshot it replaces. This fixes all four recorders. Two related fixes keep empty snapshots correct. DataRecorder only pops the last block on an overwrite if that block is from the same time, so replacing an empty snapshot no longer drops an earlier one. JSONDataRecorder no longer turns an empty snapshot into a placeholder row, matching the other recorders. Fixes mesa#3967
|
Performance benchmarks:
|
quaquel
reviewed
Nov 6, 2026
quaquel
left a comment
Member
There was a problem hiding this comment.
I understand the code, but I fail to understand the bug. Should is_overwrite not simply remove all old data?
Also, I noticed, that is_overwrite is missing from the signature in base data recorder, so while you are at it, could you include that in this PR.
This was referenced Nov 10, 2026
This was referenced Nov 20, 2026
Open
Member
|
Closing this as stale. |
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.
All four data recorders repeated every
TableDataSetrow once per snapshot and stamped rows with times before they were added. Three rows overrun_for(3)came back as 9 rows fromDataRecorderand 12 fromJSONDataRecorder.Bug / Issue
Fixes #3967.
TableDataSet.datareturns its liverowslist.DataRecorder,JSONDataRecorder,ParquetDataRecorderandSQLDataRecorderstored that whole list at every snapshot, so a table's output contained every row once per snapshot, including snapshots taken before the row existed.Implementation
BaseDataRecorder._snapshot_data()builds the data for every snapshot: time changes,RUN_ENDEDand manualcollect(). For aTableDataSetit returns only the rows added since the previous snapshot. For an overwrite it returns the rows since the start of the snapshot being replaced. Other datasets are passed through unchanged. This fixes all four recorders in one place.TableDataSetis imported inside the method becausedataset.pyimports this module (the same pattern asmesa_signals/core.py).DataRecorder: an overwrite now pops the last block only if it is from the same time. An empty snapshot stores no block, so replacing one used to pop the previous time's block and lose its rows. With incremental tables, empty snapshots are common.JSONDataRecorder.get_table_dataframe()no longer turns an empty snapshot into a placeholder row (value=[]with NaN fields). The other three recorders already produce no rows for an empty snapshot.Testing
test_table_dataset_rows_recorded_once, run for all four recorders. A model adds one row per step except at time 3, and runsrun_for(3)thenrun_for(2), so the emptyRUN_ENDEDsnapshot at time 3 is overwritten. It checks that each row appears once, with the time it was recorded.mainand passes with the fix. Removing only theDataRecordertime check makes theDataRecordercase fail again.tests/experimental/test_datarecorder.pyandtests/experimental/test_dataset.pypass.test_suppressed_wake_is_logged_at_debug, which also fails on unmodifiedmain(Importing the Boltzmann example app disables MESA log propagation, breaking caplog in later tests #3935).ruff checkandruff format --checkare clean.Additional Notes
start_time, are included in that first snapshot.clear(), rows that were already recorded are not recorded again; recording continues with new rows.