Skip to content
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

[REQUEST] Shortening error messages of certain modules similarly to frame suppression in tracebacks #3271

Open
ibro45 opened this issue Feb 3, 2024 · 2 comments

Comments

@ibro45
Copy link

ibro45 commented Feb 3, 2024

How would you improve Rich?

Allow automatic shortening of error messages. Could be implemented similarly to frame suppression. A shortened message would keep only, for example, 3 lines, and the number of lines could be controlled similarly to max_frames in Traceback

What problem does it solve for you?

Chained exceptions can get quite long in frameworks that build on top of several other codebases. The error messages in some of the exceptions in the chain can be almost certainly always useless. Shortening them would make debugging way simpler.

In my framework, I would by default have certain modules' error messages shortened/supressed automatically, unless the debug mode is activated.

For example, the RuntimeError here:

image

Would become this if max_error_lines=3 (or whatever the name would be):

RuntimeError: Failed to instantiate component 'lighter.utils.model.adjust_prefix_and_load_state_dict' with kwargs: {'ckpt_to_model_prefix': 
{'_orig_mod.': ''}, 'ckpt_path': '/mnt/ssd1/rogueone/ibro/CT_FM/ct_fm_nsclc/checkpoints_8_Jan_2024/random_init_100/epoch=152-step=6579.ckpt', 
'model': SegResNetDS(
...

Alternative
Please let me know if there is already a way to achieve this. Also, if this is something that you would indeed like to have, feel free to briefly instruct me in how it could be achieved and I would be happy to try to make a pull request.

Copy link

github-actions bot commented Feb 3, 2024

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@ibro45
Copy link
Author

ibro45 commented Feb 3, 2024

or, alternatively, add an option to just shorten the error messages of the already suppressed modules. That won't be as complex and will probably be just enough amount of control -- in my case, that would actually be perfect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant