Skip to content

Fix emperor_dilemma: resolve relative imports and update SpaceRenderer API#338

Open
mehaksalil wants to merge 3 commits intomesa:mainfrom
mehaksalil:fix-emperor-dilemma
Open

Fix emperor_dilemma: resolve relative imports and update SpaceRenderer API#338
mehaksalil wants to merge 3 commits intomesa:mainfrom
mehaksalil:fix-emperor-dilemma

Conversation

@mehaksalil
Copy link

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
Copy link
Author

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.

@codebreaker32
Copy link
Contributor

codebreaker32 commented Mar 1, 2026

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

The example now runs correctly.

Tests are failing

@mehaksalil mehaksalil force-pushed the fix-emperor-dilemma branch from 7bc3899 to 7be96d9 Compare March 1, 2026 12:18
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.

Fix emperor_dilemma: relative imports and outdated SpaceRenderer API

2 participants