-
Notifications
You must be signed in to change notification settings - Fork 1k
Feat: Added Command Console #2697
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
Feat: Added Command Console #2697
Conversation
for more information, see https://pre-commit.ci
Performance benchmarks:
|
I would love to hear your thoughts on this, @quaquel. |
I think this is really nice. Unfortunately, I don't have time to play around with it at the moment. However, I know you have been testing this extensively. I'll try to review soon, but I have various other obligations at the moment. |
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.
Code looks clear and well documented. Great stuff!
I still want to try this myself before approving. Hopefully later today if all goes well.
Started playing with it. I think it's great. Below is a WIP list of things I run into. Not all of this needs to be addressed in this PR.
|
Don't know yet, it doesn't seem very plausible because those are the imports we can't see. Will try to find a way.
Glad to know.
This feature makes sense, I will try to incorporate it.
I think I've added that already in the recent commits, I also realized that was very annoying, that's why I added
Most likely possible, but I will have to go through the solara documentation thoroughly for that (because just adding the enter took long enough).
same as the answer in the 5th. Plus I would love to get this PR merged and look back at the code when implementing the variable explorer, because that will also take up some space. |
Thanks for the responses. None of these comments are blocking approval. They are merely a wishlist from my side.
|
|
Auto-scrolling is implemented, simple fix I found was to use |
Thank you very much @quaquel for starting the review. I, too, wanted to try it out before reviewing this PR. But I still haven't found the time to dedust my local mesa workspace.
This should be quite important. I think it would be good to take those (very good) ideas to a follow-up PR and try to merge this soonish. Its an awesome PR, I can already tell without doing a proper review right now. |
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 am reviewing the code atm. One request: can you add the console stuff to /docs/apis/visualization.md
? I am wondering if some of the docstrings will render correctly.
I don't see any other obvious things that should be changed and have tested the console locally, so I think this is almost ready to merge.
I don't know how the doc stuff works, should I add this? \## Command Console
\```{eval-rst}
\.. automodule:: mesa.visualization.command_console
:members:
:undoc-members:
:show-inheritance:
\``` ignore the '\' |
yes that should probably work |
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.
2 minor doc comments, but otherwise good to go.
Amazing work!
I will inform once I get the docs right, they seem a little off. |
Yeah docs look good now, its good to go! |
It would be good to open an overview issue with a wishlist of possible extensions based on the ideas discussed here. |
Congratulations on getting this PR merged! Awesome feature already and really excited in what it can involve into! |
Summary
Adds a command console in mesa as per #2683.
Closes #2683.
Implementation
This feature consists of four main classes:
ConsoleEntry
: Defines how the data is entered into the console.CaptureOutput
: A context manager for capturing stdout and stderr output.InteractiveConsole
: A custom interactive Python console with output capturing capabilities. This class extendscode.InteractiveConsole
for a console like behaviour.ConsoleManager
: A console manager for executing Python code interactively. This class provides functionality to execute Python code in an interactive console environment, maintain command history, and handle multi-line code blocks.For more information refer to the docstrings in the file.
Usage Examples
How it looks: