-
Notifications
You must be signed in to change notification settings - Fork 943
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
deploy/publish multiple models in a single webapp ? #1800
Comments
You are in an uncharted territory. #481 is the past issue when the old Tornado viz ( |
Ok. I'll report back with how it goes using flask + solara for our models, maybe it will be a useful approach for others. |
Reporting back on this - flask isn't actually needed, you can just combine the existing solara apps as components into a single solara app. Here's the code for how I'm doing it currently for my project: https://github.com/Princeton-CDH/simulating-risk/blob/main/simulatingrisk/app.py And here's a screenshot of the app that shows how you can toggle between the simulations: |
That's great. We should document this in a howto page, just like in the Solara docs (https://solara.dev/docs/howto) -- they are structured based on https://diataxis.fr/ (tutorial, how-to guides, explanation, and reference). There are https://github.com/projectmesa/mesa/blob/main/docs/useful-snippets/snippets.rst and https://github.com/projectmesa/mesa/blob/main/docs/best-practices.rst. But I think snippets.rst should be renamed to howto.md. I will change it. Is there a reason why it has to be |
I tried using the |
I will investigate. |
I think it's because the |
Ah, I see, that makes sense. If we had a method to instantiate the page could we import and call that to generate a new instance, instead of wrapping the page? |
Yes, but it amounts to moving the component definition to each app.py (e.g. simulatingrisk/hawkdove/app.py) @solara.component
def page():
return JupyterViz(
HawkDoveSingleRiskModel,
jupyterviz_params,
measures=[plot_hawks],
name="Hawk/Dove game with risk attitudes; all agents have the same risk attitude",
agent_portrayal=agent_portrayal,
space_drawer=draw_hawkdove_agent_space,
)
# required to render the visualization with Jupyter/Solara
page() In the main app.py
|
Is there a standard way to publish interactive Mesa models on the web? I'm particularly interested in publishing multiple related models together. I'm wondering about setting up a webapp on a sandbox/dev server as an alternative to using Colab for project team members to work with the simulations we're developing.
It seems like the new jupyterviz / solara code may make this easier. I see from the Solara deploy documentation that Solara apps can be embedded in Flask, so it seems like it should be possible to embed multiple different solara apps at different urls within a single Flask app.
Would appreciate any advice or input on how to proceed or examples if anyone has done something like this.
The text was updated successfully, but these errors were encountered: