Skip to content

Fix empty batch_run results when model_reporters is None - #3579

Merged
quaquel merged 1 commit into
mesa:3.5.x-maintenancefrom
codebreaker32:3.5.x-maintenance
Mar 19, 2026
Merged

quaquel merged 1 commit into
mesa:3.5.x-maintenancefrom
codebreaker32:3.5.x-maintenance

Conversation

@codebreaker32

@codebreaker32 codebreaker32 commented Mar 19, 2026 •

Copy link
Copy Markdown
Collaborator

Note

Use this template for bug fixes only. For enhancements/new features, use the feature template and get maintainer approval in an issue/discussion before opening a PR.

Pre-PR Checklist

  • This PR is a bug fix, not a new feature or enhancement.

Summary

batch_run drops all agent data and returns an empty list [] if a model only uses agent reporters (model_reporters=None)

Bug / Issue

See #3311

When model_reporters is None, the simulation time step (model.time) was skipped because the recording logic was nested inside the if self.model_reporters block. Because the time steps were never recorded in _collection_steps, batch_run assumed an empty history and returned zero results.

Credits to @soelderer for finding the bug

Implementation

Hoisted the self._collection_steps.append(model.time) logic out of the model_reporters condition in DataCollector.collect(). The simulation time is now correctly recorded regardless of which reporters (model, agent, or agent-type) are active.

Testing

All tests passed locally

@codebreaker32 codebreaker32 added bug Release notes label backport-candidate PRs we might want to backport to an earlier branch labels Mar 19, 2026
@codebreaker32 codebreaker32 changed the title Fix the bug in datacollection Fix empty batch_run results when model_reporters is None Mar 19, 2026
@quaquel
quaquel merged commit 9d9eec1 into mesa:3.5.x-maintenance Mar 19, 2026
11 checks passed
@codebreaker32
codebreaker32 deleted the 3.5.x-maintenance branch March 20, 2026 03:05
EwoutH pushed a commit to EwoutH/mesa that referenced this pull request Nov 22, 2026
* Fix partial model data collection after reporter failures

Signed-off-by: Sahil Kumar Singh <[email protected]>

* test(datacollector): cover model reporter evaluation and copy failures

Signed-off-by: Sahil Kumar Singh <[email protected]>

---------

Signed-off-by: Sahil Kumar Singh <[email protected]>
Co-authored-by: Jan Kwakkel <[email protected]>

Adapted for 3.5.x: 3.5 records the collection step even without model reporters (mesa#3579), so the step is appended after the model reporter block, once all model reporters have succeeded, instead of inside it.

(cherry picked from commit 7379e9e)

Assisted-by: Claude Opus 5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-candidate PRs we might want to backport to an earlier branch bug Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants