Skip to content

Debug option for errors in visualisation #2747

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

Merged
merged 3 commits into from
Apr 5, 2025

Conversation

colinfrisch
Copy link
Collaborator

@colinfrisch colinfrisch commented Apr 2, 2025

Resolves #2745

What the problem was

I noticed that when there is an error while visualising a mesa model with solara, it only displays the error type, not the classic debugging error (document, line, etc.).
For example, I got an error AttributeError: 'my_object' object has no attribute 'len', but I didn't know what part it was referring to, as I was using dependencies to different files that I created. It would be useful to have a possibility to see the full error for debugging.

How it fixes it

I only added an option to display the error if needed.
Now, instead of displaying Error in step : [YOUR ERROR], it displays Error in step: [YOUR ERROR]. Press 'e' for full traceback , if you press any other key, it doesn't show anything. It also does not prevent you from refreshing your visualisation or resetting it.

Copy link

coderabbitai bot commented Apr 2, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@colinfrisch colinfrisch changed the title added debug option for error handling in terminal for visulisation part Debug option for errors in visualisation Apr 2, 2025
Copy link

github-actions bot commented Apr 2, 2025

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 +0.2% [-0.1%, +0.5%] 🔵 +0.3% [+0.1%, +0.5%]
BoltzmannWealth large 🔵 +0.0% [-0.5%, +0.8%] 🔵 -0.1% [-0.7%, +0.4%]
Schelling small 🔵 -0.1% [-0.3%, +0.0%] 🔵 -0.5% [-0.6%, -0.4%]
Schelling large 🔵 +11.8% [+0.1%, +23.7%] 🔵 +0.7% [-0.3%, +1.7%]
WolfSheep small 🔵 -1.3% [-1.6%, -1.0%] 🔵 -0.9% [-1.1%, -0.8%]
WolfSheep large 🔵 -1.1% [-1.6%, -0.6%] 🔵 -1.1% [-2.0%, -0.2%]
BoidFlockers small 🔵 +1.4% [+0.9%, +1.9%] 🔵 -0.3% [-0.6%, -0.1%]
BoidFlockers large 🔵 +0.9% [+0.3%, +1.4%] 🔵 +0.1% [-0.2%, +0.4%]

Copy link
Member

@tpike3 tpike3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool @colinfrisch! I also have been frustrated by the lack of traceback with the visualization and adding the e option is inspired, I would have just given them the traceback.

@Sahil-Chhoker
Copy link
Collaborator

Hello @colinfrisch, thanks for this PR, great work!
I tested it, and it works great! The only issue is that I have to press keys in the terminal. I would also have preferred it to just display the traceback automatically.

@colinfrisch
Copy link
Collaborator Author

colinfrisch commented Apr 3, 2025

@Sahil-Chhoker thanks for the feeback ! I kind of liked the idea to have the option to keep a clean interface, especially if we use the terminal for other prints, but if everybody agrees, I'll just make the error plainly display :)
I feel like @tpike3 also liked the "type 'e'" option , but I may have misinterpreted his comment.

@Sahil-Chhoker
Copy link
Collaborator

I feel like @tpike3 also liked the "type 'e'" option , but I may have misinterpreted his comment.

I think he is suggesting to remove it, can you confirm @tpike3?

Also have you tried testing it over on your model which you were having issues with? Because that is the best option to confirm its functionality. Also take a look at this article, if your haven't.

@tpike3
Copy link
Member

tpike3 commented Apr 3, 2025

I do like the idea of the 'e' option, but granted I have not used it. However, this is a fairly minor change and still an improvement, so always explore-exploit, so my bias would be to keep the 'e' and see how it plays out very easy to change.

Either way good discussion @Sahil-Chhoker and @colinfrisch

@colinfrisch
Copy link
Collaborator Author

colinfrisch commented Apr 4, 2025

Thanks for your suggestions @Sahil-Chhoker and @tpike3 !

I haven't seen anything contradictory to this approach in the article that you sent me @Sahil-Chhoker, but I learned much. Did you think otherwise regarding the method ?

I will be building a couple more models for the next weeks, so I'll be able to experiment fully the 'e' feature, I will give you guys feedback if you're interested !

Regarding the merge, I don't have the permission to make it. Are there more reviews required to implement it ?

@sanika-n
Copy link
Collaborator

sanika-n commented Apr 4, 2025

Looks good to me:)
I personally don't have a strong opinion on keeping "e", so I say we keep it at leave it for the user to decide

Copy link
Collaborator

@Sahil-Chhoker Sahil-Chhoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen anything contradictory to this approach in the article that you sent me @Sahil-Chhoker, but I learned much. Did you think otherwise regarding the method?

I just wanted you to read the alternatives, and I think the current implementation is just fine.

I found an issue about your "Press 'e'" feature, it blocks your current thread and therefore the error message on the frontend does not print but is just stuck as is.

Look at the image, here there is a mistake in agents.py file but running the model does nothing, its stuck on step 0 and you won't know the error until you see the terminal and I don't like this behavior.
image

But that's just my opinion, I leave the final decision to you, @tpike3.

@sanika-n
Copy link
Collaborator

sanika-n commented Apr 4, 2025

I haven't seen anything contradictory to this approach in the article that you sent me @Sahil-Chhoker, but I learned much. Did you think otherwise regarding the method?

I just wanted you to read the alternatives, and I think the current implementation is just fine.

I found an issue about your "Press 'e'" feature, it blocks your current thread and therefore the error message on the frontend does not print but is just stuck as is.

Look at the image, here there is a mistake in agents.py file but running the model does nothing, its stuck on step 0 and you won't know the error until you see the terminal and I don't like this behavior. image

But that's just my opinion, I leave the final decision to you, @tpike3.

Just ran a test on this myself, you are right, when there is an error, your front end just freezes and you don't realize it is an error until you check the terminal.. that can be an issue ig

@colinfrisch
Copy link
Collaborator Author

Hmm that's a problem indeed... but wasn't solara already doing it even before this PR if an error happened during the simulation ? With just the full error, does it display it on the front end ?
In all cases, I'd be glad to try and find out how to display the full error on the front end !

@Sahil-Chhoker
Copy link
Collaborator

Solara frontend did indeed fail when we are just showing the error because again there is nothing blocking the main thread. Not sure about the full error, but in my opinion the full error is useful even if its just visible on the terminal.

In all cases, I'd be glad to try and find out how to display the full error on the front end !

You are free to do so if you want, just update or maybe open a follow-up PR if this PR gets merged.

@colinfrisch
Copy link
Collaborator Author

colinfrisch commented Apr 4, 2025

@Sahil-Chhoker @sanika-n I'm quite intrigued that you guys found the fact that solara freezes while there is an error specifically with this feature, because it happened to me every time that there was an error in the program...
I'll definitely look into it !

@tpike3
Copy link
Member

tpike3 commented Apr 4, 2025

@Sahil-Chhoker @sanika-n I'm quite intrigued that you guys found the fact that solara freezes while there is an error specifically with this feature, because it happened to me every time that there was an error in the program... I'll definitely look into it !

We have this same problem with batch_run is there is an error on a different processor it will not reach I/O. Curious what you find @colinfrisch! Nice catch @Sahil-Chhoker (Again great dicussion!)

@colinfrisch
Copy link
Collaborator Author

colinfrisch commented Apr 4, 2025

Sorry for these manipulations... I accidentally closed the PR so I reopened it. By curiosity, what is left to do before the PR being merged ?

@Sahil-Chhoker
Copy link
Collaborator

What are the potential next steps before the PR being merged ?

Remove the input statements and change them with simple print statements.

@colinfrisch
Copy link
Collaborator Author

colinfrisch commented Apr 4, 2025

Remove the input statements and change them with simple print statements.

Done !

Copy link
Collaborator

@Sahil-Chhoker Sahil-Chhoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with these changes.

@colinfrisch
Copy link
Collaborator Author

I am fine with these changes.

Great ! Then we just need the review from @Corvince and it's ready to merge !

@Sahil-Chhoker
Copy link
Collaborator

Great ! Then we just need the review from @Corvince and it's ready to merge !

That won't be necessary; @tpike3, this PR can be merged.

@tpike3 tpike3 merged commit f8671b4 into projectmesa:main Apr 5, 2025
12 checks passed
@EwoutH EwoutH added enhancement Release notes label backport-candidate PRs we might want to backport to an earlier branch labels Apr 5, 2025
@EwoutH
Copy link
Member

EwoutH commented Apr 5, 2025

Congrats on having your first PR merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-candidate PRs we might want to backport to an earlier branch enhancement Release notes label visualisation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is there debugging in solara ?
5 participants