Skip to content

Fix BankReserves crash and deprecation warnings#319

Open
Rishabh-77 wants to merge 1 commit intomesa:mainfrom
Rishabh-77:fix/bank-reserves-crash
Open

Fix BankReserves crash and deprecation warnings#319
Rishabh-77 wants to merge 1 commit intomesa:mainfrom
Rishabh-77:fix/bank-reserves-crash

Conversation

@Rishabh-77
Copy link

@Rishabh-77 Rishabh-77 commented Feb 1, 2026

Fix Bank Reserves Crash and Deprecation Warnings

Description

This PR addresses several critical issues in the bank_reserves example to ensure it is GSoC-ready and follows modern Mesa standards.

Fixes

  • Race Condition Crash: Implemented ThreadSafeDataCollector in model.py to prevent ValueError during Solara visualization updates (Fixes crash "ugly browser error box").
  • Deprecation Warnings: Updated agent_portrayal in app.py to return AgentPortrayalStyle objects instead of dictionaries.
  • Initialization: Aligned BankReservesModel default parameters with SolaraViz slider defaults to prevent initial state mismatch (the "two dots" bug).
  • Batch Run: Updated model __init__ to accept rng and kwargs, fixing batch_run.py failures.

Related Issue

Fixes #318

Implement ThreadSafeDataCollector to prevent race condition crashes
in Solara visualization. Update agent_portrayal to use AgentPortrayalStyle,
fixing deprecation warnings. Adjust default model parameters to match
UI slider defaults.
@EwoutH EwoutH requested a review from Sahil-Chhoker February 12, 2026 12:09
**kwargs,
):
super().__init__()
super().__init__(seed=seed, rng=rng)
Copy link
Member

Choose a reason for hiding this comment

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

This is fixed with #317, but is should be just rng, seed is deprecated.

@tpike3
Copy link
Member

tpike3 commented Feb 22, 2026

Thanks @Rishabh-77~ Your solution highlights some issues with this example that I think has an easier fix.

I think the actual issue is that model.py init_people is set at 2 while the slider is set at 25, which makes it appear like a bug due to the discrepancy. (You have to hit reset for the slider variable to be passed as the kwarg)

As for the threading, for visualization race condition Solara has a threads option which is captured in mesa as a check box, but it is not turned on by default. However, you can enable it with adding use_threads=True in the SolaraViz

If you want you want update the init_people=25 and if you want to show the capability of threading set use_threads=True I think that solution would be more consistent with how Mesa is constructed.

Thank you again for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue: Bank Reserves Example Crashes with ValueError and Deprecation Warnings

2 participants