Repository navigation
Preserve agent type snapshots when reporters fail - #3916
Merged
Merged
Conversation
|
Performance benchmarks:
|
Contributor
Author
|
The examples job fails in VirusAntibodyModel because a sequence of length 3 is passed when creating 20 agents. The failure is in agentset.py before DataCollector runs. The build matrix, coverage and documentation checks pass. The example correction is already being handled in mesa/mesa-examples#496, so I have kept it outside this PR. |
1 task done
quaquel
approved these changes
Nov 7, 2026
EwoutH
pushed a commit
that referenced
this pull request
Nov 22, 2026
Co-authored-by: Jan Kwakkel <[email protected]> (cherry picked from commit f3dc333)
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.
Pre-PR Checklist
Summary
Preserve a complete agent type snapshot if a reporter fails during collection. Previously, collecting again at the same model time cleared the stored snapshot before evaluating every reporter, so an exception could erase previously collected data or leave only some agent types.
Bug / Issue
Fixes #3915.
Implementation
Build the records for all configured agent types in a temporary dictionary, then replace the stored snapshot after every reporter succeeds. Successful collection keeps the existing replacement behavior. The original exception still propagates.
This change is limited to agent type snapshots. It does not make model and agent collection one transaction or undo side effects inside reporter functions. It is independent of #3913, which addresses model reporter rows.
Testing
Six regression cases fail on the base implementation and pass with this change. They cover failure in the first or second agent type during initial collection, replacement at the same time, and collection at a new time. They also check the original exception object and successful retry through the stored records and exported dataframe.
The full DataCollector test module passes: 53 tests. The agent, AgentSet and model modules also pass: 67 tests. Ruff check, Ruff format check and git diff check pass.
Commands use an isolated environment with this checkout installed:
Additional Notes
The full repository suite was not run. Local coverage attempts failed during NumPy import with
cannot load module more than once per process; no coverage percentage is claimed. Normal pytest execution passes.The separate examples job has a known VirusAntibodyModel failure tracked in mesa/mesa-examples#488, with a proposed fix in mesa/mesa-examples#496. This PR does not change that example or disable checks.