-
-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
Describe the bug
SimulationRecorder.save() unconditionally appends a simulation_end event every time it is called. When a user calls save_recording() manually and then the atexit auto-save handler fires at program exit, the output file contains two simulation_end entries.
Expected behavior
simulation_end is recorded exactly once, regardless of how many times save() is called.
To Reproduce
import tempfile
from unittest.mock import MagicMock
from mesa_llm.recording.simulation_recorder import SimulationRecorder
model = MagicMock()
model.steps = 5
model.agents = []
model.__class__.__name__ = "TestModel"
model.max_steps = 10
with tempfile.TemporaryDirectory() as tmp:
recorder = SimulationRecorder(model=model, output_dir=tmp)
recorder.save("first_save.json")
recorder.save("second_save.json")
ends = [e for e in recorder.events if e.event_type == "simulation_end"]
print(len(ends)) # this prints 2 where 1 is expectedAdditional context
currently, each call to save() appends a new simulation_end event.
I will be raising a pr fixing this.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels