-
Notifications
You must be signed in to change notification settings - Fork 939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include examples in readthedocs #2382
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome!
This also epitomizes to me why we want those seminal models in the main repo so we can ensure they are current with whatever Mesa version we are on.
To run the model interactively, run ``mesa runserver`` in this directory. e.g. | ||
|
||
``` | ||
$ mesa runserver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be updated to the new visualization approach
* ``agents.py``: Defines the behavior of an individual cell, which can be in two states: DEAD or ALIVE. | ||
* ``model.py``: Defines the model itself, initialized with a random configuration of alive and dead cells. | ||
* ``portrayal.py``: Describes for the front end how to render a cell. | ||
* ``st_app.py``: Defines an interactive visualization using Streamlit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be updated for new set agents and app
docs/examples/virus_on_network.md
Outdated
To run the model interactively, run ``mesa runserver`` in this directory. e.g. | ||
|
||
``` | ||
$ mesa runserver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be updated with Solara
import altair as alt | ||
import numpy as np | ||
import pandas as pd | ||
import streamlit as st |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still want to use streamlit or update to Solara?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in my view, we standardize all examples on solara
To run the model interactively, run ``mesa runserver`` in this directory. e.g. | ||
|
||
``` | ||
$ mesa runserver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update to Solara?
docs/examples/virus_on_network.md
Outdated
|
||
For more information about this model, read the NetLogo's web page: http://ccl.northwestern.edu/netlogo/models/VirusonaNetwork. | ||
|
||
JavaScript library used in this example to render the network: [d3.js](https://d3js.org/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be removed
@@ -0,0 +1,61 @@ | |||
# Virus on a Network |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these in two places?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old one wasn’t removed, so there are now two Readme files.
@tpike3, I agree with most of your comments regarding the content of the examples, but can we leave that for a separate PR and focus this one on just including the examples in the docs in the first place? The updated conf.py ensures that any updates in the readme, agent.py, model.py, and app.py result in an updated page in the docs. |
One question, why does it add so much additional files? Aren't all/most of those files in the repo already? |
|
Thanks for the explanation. I will be honest, I don't like these monster PRs that do multiple things and are quite far away from an atomic change. There's a big chance something slips up in there. I also do recognize real-world development flows and practical limitations.
Is there anyway we can not keep these files in our history, since they are autogenerated from existing content and thus 100% duplicate. I suspect this will trigger (huge) CI issues and changesets when updating examples or working on other stuff. I see two options:
For me 1 is preferred, but 2 is also acceptable. The other files are fine, renames and cleanups look good. Ideally the warnings cleanup would be a separate PR, but I do recognize how this goes so for now its fine from my part. |
conf.py handles all this so there should not be a problem. I prefer to have them in the history because otherwise rtd has to first regenerate the md files and then regenerate the html pages every single time. Having them in git speeds up the building of docs because they are only recreated by RTD if the associated example Python files are updated. |
But that means every time I update an example, the all the changes will be duplicate into the PR diff. I find that to be a major downside. Can't we cache them elsewhere, and just hash the source files and templates use to check for cache hits? Sorry to make this PR more complicated, but this duplication is something I really really would like to avoid. |
This only happen if you build the docs yourself locally and commit those changes. Also there is a single md file per example, so I am not sure what the problem is. |
The simpler solution would be to just always rebuild the md files and ignore them via gitignore, but I fail to see what the problem is with the current solution as explained above. |
That's a totally acceptable solution for me right now. We can add caching later if that seems to be needed.
Basically, each change to the examples would have a completely duplicate diff, as both the example itself and generated readme is changed in exactly the same way. |
I guess you mean markdown rather than readme. As indicated, this only happens if you build the docs locally. Who does that other than when developing and testing doc-related things? Note that this approach has been used for the workbench for several years. Have you ever run into this potential diff problem there? I am happy to change it but I still fail to see the problem here. |
But if these files are tracked/included in git, but not updated in a PR, when are they updated? And why does this PR have them? (signing off for today, will reply tomorrow) |
If not updated in the PR, Regardless, I have made the change you requested. The example related markdown files are now in gitignore and conf.py just allways creates them on RTD when building docs. |
Okay, so they are only generated within Sphinx / Readthedocs, and not tracked in git by default. So it’s already like the preferred solution I proposed. When committing, please check which files you want to include in the PR and which files are just local because you tested / experimented with some things. Two remaining points, then we can properly review:
|
It's a bit more complicated than you make it out to be. But I don't want to continue arguing the point. I don't see two readme files that are identical, neither in my IDE nor in my file explorer. Please can you be explicit which files according to you are duplicated? Including both app and st_app if they both exist and only either one, if they exist, is tricky with string templates. I actually experimented with trying to get that to work but it did not render nicely. So happy to take yet another stab at it but it's not entirely trivial as far as I can tell. Moreover, from a future proofing point of view, my preference would be to standardize on app.py and only showcase solara visualizations. If there is any file duplication, it happened after rebasing because of the examples --> mesa.examples move. This rebase broke somehow GitHub Desktop and I had to resort to the command line. |
May I clean up the PR? |
go ahead |
I tried doing a proper rebase, but the git threw a few errors I never have seem before. So I ported the changes over manually in #2392. |
solved via #2392 |
This updates conf.py to create markdown files for including the examples in the documentation. It also cleans up some warning on RTD, which happened while debugging the code. In this process, this also fixes #2360.
It currently only covers the basic examples because the advanced examples are not fully cleaned yet.