Repository navigation
Import MetaAgents from its new home in mesa.experimental - #499
Conversation
The Meta-Agents Rewrite (mesa/mesa#3811, mesa/mesa#3875) moved the package from mesa.meta_agents to mesa.experimental.meta_agents, and mesa no longer exports meta_agents at the top level. The warehouse example still imported the old path: from mesa.meta_agents import MetaAgents Since test_examples.py imports every model module, that ModuleNotFoundError aborts collection, so the whole examples suite fails before a single test runs. That is the examples job currently red on mesa main, and therefore on every open mesa PR. mesa's own migration guide gives the new path: "Meta-agents still live in mesa.experimental.meta_agents". Nothing else in the example needs changing, since the rest already uses the rewritten API through model.meta_agents. Against mesa main, test_examples.py goes from 1 collection error, 0 tests run to 24 passed / 1 failed. The remaining failure is VirusAntibodyModel, a separate pre-existing bug fixed by mesa#496.
|
Some evidence on how long this has been broken, and a correction to my own note above. First the correction: I suggested a scheduled run against mesa The gap is that the scheduled run has been failing every Monday since 14 September, nine weeks: A canary that has been red for nine weeks stops being a signal, which is why this particular rename could sit unnoticed until it turned up in unrelated contributors' PRs. The part I had wrong in the PR description, and which makes this more urgent than I claimed: both CI jobs fail on it, not just the one that tracks mesa
Two independent causes account for the whole nine weeks, and both are now in flight:
I verified the interaction locally against a worktree of current mesa |
|
@tpike3 @quaquel — could one of you take a look when you have a moment? It is a one-line import change, and it is currently the thing holding the examples suite down. Short version: the Meta-Agents Rewrite moved the package to Why it is worth a few minutes rather than sitting in the queue:
One practical thing that would help: the The one remaining failure after this is No rush if you are mid-release — mainly flagging that the blast radius is wider than the one-line diff suggests. |
|
@quaquel — gentle nudge on this one, with a bit of context I did not have when I first pinged. I had assumed this PR was simply queued. Looking at the repo, that is not quite it: nothing has merged here since 14 September, and the last non-bot PR was #483 on 31 August. There are 79 open PRs, the oldest from December 2025. So this is a review-capacity problem rather than anything about this change, and I do not want to add noise to it. The reason I am nudging anyway is that this particular one is not just another queued example fix — it is the thing keeping the
The diff is one import line. #483 moved this example onto the new meta-agents API, and the later move of the package into -from mesa.meta_agents import MetaAgents
+from mesa.experimental.meta_agents import MetaAgentsIf it is easier, the Happy to leave it be if the queue is the queue — mainly wanted the nine-weeks-of-red and the published-pre-release part on the record, since neither is obvious from a one-line diff. |
…error (#502) * Report an unimportable example as one failing test, not a collection error `get_models()` runs inside the `@pytest.mark.parametrize` decorator, so every `model.py` under `examples/` is imported while pytest is still collecting. The import is unguarded, so one `ImportError` propagates out of collection and pytest stops with ERROR test_examples.py Interrupted: 1 error during collection That is not one failing example. It is zero tests run, for every example in the repository, and the summary line says nothing about the other 25. This is what made the recent breakages invisible rather than merely broken. The warehouse example's stale `mesa.meta_agents` import (#499) aborted collection, so mesa's own `examples` job went red and stayed red for 24 consecutive runs on `main` without ever reporting on the examples that were fine. A new breakage introduced during that window would have looked identical to the standing one. Guard the import and turn a failure into a single parametrized case that fails with the underlying exception, keyed by module name. One broken example now costs exactly one red test. Demonstrated on 9112701 by adding a throwaway example whose `model.py` imports a missing module: before 1 error in 11.87s (Interrupted during collection, 0 ran) after 1 failed, 25 passed (FAILED ...[examples.zz_broken_demo.model]) With a healthy tree the behaviour is unchanged: 25 passed, and the test ids for working examples stay as they were (`test_model_steps[AcoTspModel]`). Co-Authored-By: Claude Opus 5 <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Claude Opus 5 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Summary
The warehouse example imports
MetaAgentsfrom a module that no longer exists, which aborts collection for the whole examples suite.The Meta-Agents Rewrite (mesa/mesa#3811, mesa/mesa#3875) moved the package to
mesa.experimental.meta_agents, and mesa no longer exportsmeta_agentsat the top level.Bug / Issue
test_examples.pyimports every model module, so this is not one failing test — collection stops and nothing runs:That is the
examplesjob currently red on mesamain(run 39246413239), and so on every open mesa PR.Implementation
mesa's migration guide gives this path directly: "Meta-agents still live in
mesa.experimental.meta_agents". Nothing else in the example needs changing — the rest already uses the rewritten API throughmodel.meta_agents(create,members_of,groups_of,query_memberships), so only the import was stale. Ruff moved the line up to keep import order.Testing
Against a worktree of current mesa
main:test_model_steps[WarehouseModel]passes, andexamples/warehouse/app.pyimports cleanly and builds itspage.The one remaining failure is
test_model_steps[VirusAntibodyModel]—ValueError: sequence of length 3 does not match the number of agents (20). That is a separate pre-existing bug, fixed by #496 (with the duplication half in #498). The import error was masking it; with this merged, #496 should take the job fully green.ruff check,ruff format,pyupgrade,codespellall pass.Additional Notes
Worth a thought for maintainers: mesa's CI runs mesa-examples against mesa
main, so a rename in mesa breaks this repo with no signal until a mesa PR goes red. Nothing here needs to change for that, but a periodic scheduled run against mesamainon this repo would surface it where it can be fixed.