projectmesa / mesa

Mesa is an open-source Python library for agent-based modeling, ideal for simulating complex systems and exploring emergent behaviors.
https://mesa.readthedocs.io
Apache License 2.0
2.52k stars 883 forks source link

Tracking issue: Full integration of Example models #2364

Open EwoutH opened 1 month ago

EwoutH commented 1 month ago

With the core examples being merged back into Mesa in #2358 and now available in examples we can now start working our checklist:

Feel free to add items, and put your name behind something if you want to pick it up!

quaquel commented 1 month ago

I'll pick up the read the docs stuff as discussed today.

EwoutH commented 1 month ago

@quaquel Awesome! #2365 structures all basic example models to have a flat structure and at least agents.py and model.py, I think that should help.

EwoutH commented 1 month ago

I'm going to focus on my thesis for a few days, but happy to review anything!

Corvince commented 1 month ago

Just a heads-up that this broke the docs build for the visualization tutorial, because mesa-examples does no longer provide the BoltzmannWealthModel. The vis tutorial does need a larger update anyways (which I somewhere agreed to do), but still this is a major breaking change that we need to communicate somehow. https://readthedocs.org/projects/mesa/builds/25963527/

Or maybe easier is to provide the same "model export" in core mesa and then just re-export that from mesa-examples. Thats probably the better path now that I think of it. I'll add "make examples importable" to the checklist

Corvince commented 1 month ago

[ ] Discuss enabling ruff and/or ruff-format on (parts of) the examples (in pyproject.toml).

Curious as to why this needs a discussion? I am strongly in favor of enabling it. Whats a reason against it?

EwoutH commented 1 month ago

Just a heads-up that this broke the docs build for the visualization tutorial, because mesa-examples does no longer provide the BoltzmannWealthModel.

I just noticed it also. That's just an question of updating the path to import from mesa/examples/basic, right?

Let's give @tpike3 a chance to finish his tutorial and then go from there.

Curious as to why this needs a discussion? I am strongly in favor of enabling it. Whats a reason against it?

Against: It's a lot of work ;). I made an start in https://github.com/projectmesa/mesa/pull/2370. Docstring we should consider if we want to add and require that everywhere.

quaquel commented 1 month ago

I agree its some work but not as bad as what I did a few weeks back with the docstrings. With @Corvince, I believe that we should just enable it and fix all issues. The examples should exemplify good practices.

EwoutH commented 1 month ago
  • Make examples importable (e.g. from mesa.examples import BoltzmannWealthModel)

@Corvince this means we also have to move them from examples to mesa/examples, right? Or can we make them importable in another way?

Corvince commented 1 month ago

Not sure, I checked and experimented briefly. There is an extensive hatch documentation about file selection https://hatch.pypa.io/latest/config/build/#file-selection

From skimming it might be possible from examples, but I don't know if it can automatically be included as "mesa.examples". Someone should figure this out

EwoutH commented 2 weeks ago

@quaquel if you can find the time, having the examples sorted by Basic and Advanced would be really useful, as well as having the Readme descriptions integrated.

I'm good with making that whole Readme the starting page for https://mesa.readthedocs.io/latest/examples.html, even if it then looks less good on GitHub (or the links only work on Readthedocs, etc.). Renaming headers etc. is also okay.

image

quaquel commented 2 weeks ago

The example level readme is already included. I hope to find some time this weekend to do the overview of examples readme.