-
Notifications
You must be signed in to change notification settings - Fork 880
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
Support simulators in SolaraViz #2470
Conversation
Performance benchmarks:
|
Just a quick remark: the issue of the |
Thanks for working on this. Do you think it will be a user-API breaking change? |
No, this won't be API breaking. For solara_viz, it adds an optional keyword argument. For DEVS, it slightly changes the behavior of some methods but does not change the public API. |
Great, let me know when it's ready for review. |
True. But for the issue at hand, I think we don't actually need to monkey patch step at all. It should be enough to call force_update() at do_step(). Monkey patching was I think mainly to allow triggering updates from the outside when stepping through the reactive model. But this should be handled separately from how solara viz works internally. Could you try if that works? |
If I only add force_update to |
and move force_update into do_step
for more information, see https://pre-commit.ci
I did not anticipate the weird behavior, but yes, I think the monkey patching is actually not needed. |
The weird behavior comes from |
for more information, see https://pre-commit.ci
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.
I will let the SolaraViz part to Corvince, a few comments on the DEVS side
Since there are some substantial changes to DEVS, it might be nice to make it two PRs: First one with the DEVS changes and then one with the SolaraViz ones. |
I was afraid that you would suggest that, and I agree (but don't want to). I'll do it tomorrow. |
Yes, splitting off the DEVS fixes was the right call. This is now a beautifully clean changeset I will gracefully hand over to @Corvince. |
4 Things i noticed on a first look
That's it for now, should be easy to change/clarify and then we are good to go 👍 |
Thanks! I addressed points 1-3.
I agree on point 4. I'll take a closer look hopefully later today and see if I can reduce the duplication. |
for more information, see https://pre-commit.ci
I had a closer look at point 4. Indeed, the only difference between |
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.
True, let's leave it for now!
This adds support for
Simulator
toSolaraViz
. This closes #2428.While working on it, I discovered a few subtle bugs in
experimental.devs
and thewolf-sheep
benchmark model. These changes have been merged via #2478. This PR only contains the updates tosolara_viz
.The modular nature of SolaraViz works great and makes it easy to simply add a SimulatorController. However, as part of this, there are two key behavioral changes introduced:force_update
moved into thedo_step
method, rathen than being called via monkey patching model.step. This is a required change to make it work with simulator.ABMSimulator
schedulesmodel.step
whensimulator.setup(model)
is called. This happens before the monkey patching, so the event calls the non-monkey patched step method, resulting in no force_update being called.I also updated wolf-sheep and rewrote it to use event scheduling.
Given some of the SemVer discussions: the changes in solara_viz are fully backward compatible.