Replies: 1 comment
-
Closing this discussion in favor of: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Update: Further discussed here:
Objective
Modify the JupyterViz component to allow direct access and modification of the model instance, both from the Solara interface and the Python interpreter.
Basically allow things like:
which ideally, also updates the interface and visa versa.
Rationale
Currently, the JupyterViz component encapsulates the model, making it difficult for users to interact with or modify the model directly. This enhancement will provide greater flexibility and control, allowing users to:
These capabilities will be particularly useful for debugging, advanced simulations, and integrating Mesa models with external systems or workflows.
Implementation
1. Refactor JupyterViz as a Class-Based Component
Convert JupyterViz from a function to a class-based component. This allows us to maintain state and provide methods for external interaction.
2. Use Solara State for Model Management
Utilize Solara's state management to handle the model instance, ensuring updates are reflected in the UI.
3. Implement Model Interaction Methods
Add methods for common model interactions:
4. Expose Model Parameters
Make model parameters accessible and modifiable:
5. Update Rendering Logic
Modify the
render
method to use the new state-based model and provide basic UI controls:Usage Examples
Initialization
Interacting with the Model from Python
Extending the Component
Users can extend the JupyterViz class to add custom functionality:
Beta Was this translation helpful? Give feedback.
All reactions