Skip to content

Explain what clear() does with files on disk in the JSON and Parquet recorders - #4079

Merged
EwoutH merged 2 commits into
mesa:mainfrom
AshNicolus:docs/recorder-clear-files
Nov 14, 2026
Merged

EwoutH merged 2 commits into
mesa:mainfrom
AshNicolus:docs/recorder-clear-files

Conversation

@AshNicolus

Copy link
Copy Markdown
Contributor

Pre-PR Checklist

  • This PR fixes missing documentation, not a new feature or enhancement.

Summary

Makes the clear() docstrings of JSONDataRecorder and ParquetDataRecorder say what happens to files on disk.

Bug / Issue

Fixes #4054

The two recorders treat files differently on clear(), and the docstrings didn't explain why. As @codebreaker32 pointed out in the issue, both behaviours are right for their backend:

Recorder Where the data lives What clear() does with files
JSONDataRecorder in memory, save_to_json() exports it leaves saved .json files alone
ParquetDataRecorder in the .parquet file itself deletes the file

Implementation

Docstrings only, no behaviour change.

  • JSONDataRecorder.clear(): files already written by save_to_json() stay on disk, and the next save_to_json() overwrites them.
  • ParquetDataRecorder.clear(): was "Delete Parquet files.", now explains that the files are where the data is kept, so clearing deletes the file and empties the write buffer.

DataRecorder and SQLDataRecorder already describe what they clear, so I left them.

Testing

  • Checked the behaviour the docstrings describe: after clear() the .json file is still there and the next save replaces its contents (times 0 to 3 before, 3 to 5 after), while the .parquet file is gone and the recorder returns no rows.
  • pytest tests/ -Werror -Wdefault::PendingDeprecationWarning: 1118 passed. Pre-commit passes.

@github-actions github-actions Bot added the experimental Release notes label label Nov 13, 2026
@github-actions

Copy link
Copy Markdown

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 +0.3% [-0.1%, +0.6%] 🔵 +0.8% [+0.5%, +1.0%]
BoltzmannWealth large 🔵 +1.5% [+1.1%, +2.0%] 🔵 +2.5% [+1.2%, +3.7%]
Schelling small 🔵 +1.1% [+0.6%, +1.5%] 🔵 -1.3% [-2.0%, -0.6%]
Schelling large 🔵 +0.4% [+0.1%, +0.8%] 🔵 -0.2% [-1.6%, +1.4%]
WolfSheep small 🔵 -0.0% [-0.5%, +0.4%] 🔵 -1.5% [-5.3%, +2.5%]
WolfSheep large 🔵 +0.3% [-0.2%, +0.9%] 🔵 -1.0% [-1.9%, +0.0%]
SugarscapeG1mt small 🔵 +0.4% [+0.1%, +0.7%] 🔵 +0.2% [-1.5%, +2.0%]
SugarscapeG1mt large 🔵 -0.2% [-1.1%, +0.4%] 🔵 -1.1% [-3.5%, +1.2%]
BoidFlockers small 🔵 -0.0% [-0.6%, +0.5%] 🔵 +1.3% [+0.9%, +1.8%]
BoidFlockers large 🔵 +0.2% [-0.3%, +0.7%] 🔵 +0.1% [-0.2%, +0.5%]
MultiLevelAllianceModel small 🔵 -0.4% [-1.1%, +0.3%] 🔵 -1.9% [-2.6%, -1.2%]
MultiLevelAllianceModel large 🔵 -0.1% [-0.7%, +0.6%] 🔵 -0.6% [-1.3%, +0.3%]


def clear(self, dataset_name: str | None = None) -> None:
"""Delete Parquet files."""
"""Clear recorded data by deleting the Parquet files.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Clear recorded data by deleting the Parquet files.
"""Clear recorded data by deleting the Parquet file(s).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 3b56f41, thanks!

@codebreaker32 codebreaker32 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, just a small nitpick, otherwise LGTM!

@EwoutH EwoutH left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, checked both docstrings against the code; accurate.

@EwoutH
EwoutH merged commit 17deb72 into mesa:main Nov 14, 2026
16 checks passed
EwoutH pushed a commit that referenced this pull request Nov 22, 2026
…recorders (#4079)

* Explain what clear() does with files on disk in the JSON and Parquet recorders

* Say Parquet file(s) in the clear() docstring

(cherry picked from commit 17deb72)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

experimental Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should DataRecorder.clear() remove saved files? JSON and Parquet differ

3 participants