mesa-examples icon indicating copy to clipboard operation
mesa-examples copied to clipboard

Fix emperor_dilemma: resolve relative imports and update SpaceRenderer API

Open mehaksalil opened this issue 9 months ago • 3 comments

Fixes #337

The emperor_dilemma example was broken and could not be run due to two issues:

  1. Relative imports across app.py, model.py, and agents.py were incompatible with how Solara loads example modules. Changed to absolute imports.

  2. SpaceRenderer.setup_agents() no longer exists in the current Mesa API. Updated to use the current .render(agent_portrayal=...) pattern, consistent with other examples like rumormill.

  3. Applied ruff formatting fixes.

The example now runs correctly.

mehaksalil avatar Feb 25 '26 20:02 mehaksalil

The absolute imports are required for Solara to run the example locally (solara run app.py). Relative imports break Solara's module loading. Looking for guidance on how other examples handle this CI/Solara conflict.

mehaksalil avatar Feb 27 '26 13:02 mehaksalil

I really can't understand the motive of this PR.

The example now runs correctly.

Tests are failing

codebreaker32 avatar Mar 01 '26 06:03 codebreaker32

Hey! I'm also a GSoC 2026 candidate working on mesa-examples — I've been working on the Emperor's Dilemma model too so I noticed your PR. My PR #443 extends it with WhistleblowerAgent and a belief gap metric. Would you be open to reviewing it in return? Happy to review yours as well!

TheMS1314 avatar Mar 28 '26 20:03 TheMS1314