-
Notifications
You must be signed in to change notification settings - Fork 929
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
Convert make_space into solara components #1789
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1789 +/- ##
==========================================
- Coverage 79.88% 79.43% -0.45%
==========================================
Files 15 15
Lines 880 890 +10
Branches 188 192 +4
==========================================
+ Hits 703 707 +4
- Misses 154 160 +6
Partials 23 23
☔ View full report in Codecov by Sentry. |
This is how Solara does it: https://github.com/widgetti/solara/blob/baa36623c3eb7db50672d8eb3d3cdab9220a50a6/solara/components/matplotlib.py#L11, add an optional argument |
No, this is the opposite. This is used to limit the number of re-renders, where I want to trigger a re-render. I mean the idea of passing and additional, changing prop works and this is what my solution 1) refers to (and what i got recommended on discord). But the dependencies argument in Solaras FigureMatplotlib in particular is meant to do the opposite. |
Added the additional prop for now - still not completely happy with this solution but at least it works right now |
def make_space(model, agent_portrayal): | ||
def portray(g): | ||
@solara.component | ||
def GridView(grid, agent_portrayal, dummy): |
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.
dummy
as a name is rather non-descriptive and confusing.
Reason to close this PR #1805 (comment) |
In this PR I wanted to convert the
make_space
function into aSpaceView
component that handles all the aspects of drawing the model space.However, as it is now, it doesn't work, because in contrast to React solara uses lazy rendering. That is child component only rerender if their props change. But with SpaceView I am only passing space_drawer, model and agent_portrayal. And those don't change with each step. I found two workarounds
@solara.component
from SpaceView and its children. Thus converting them to normal functions that return solara components.Both approaches seems rather hacky. Maybe someone else has any ideas?