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] environmental variable to disable rich traceback #3640

Open
matthewfranglen opened this issue Feb 25, 2025 · 7 comments
Open

[REQUEST] environmental variable to disable rich traceback #3640

matthewfranglen opened this issue Feb 25, 2025 · 7 comments

Comments

@matthewfranglen
Copy link

How would you improve Rich?

I am using huggingface transformers to train a model in a project with a bunch of dependencies. One of those dependencies is installing the rich traceback.

When there is an error then over two thousand lines of output are printed because the model is serialized on almost every frame (>100 lines of output) along with large tensors, dataframes etc. This makes the stack trace unusable.

I cannot control the fact that rich.traceback.install has been called somewhere. It would be nice if I could set an environmental variable that would prevent the installation from taking effect.

What problem does it solve for you?

I would be able to read and understand the stack trace that is produced.

Copy link

We found the following entry in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@TomJGooding
Copy link
Contributor

Sorry if this is stating the obvious, but wouldn't it make sense if this was configurable in whatever dependency has installed Rich tracebacks?

@matthewfranglen
Copy link
Author

How can I reliably find that?

@matthewfranglen
Copy link
Author

This seems to be an issue that others have encountered and have proposed truncating locals for: #1810

Broadly I like rich and this is an edge case. The length of the output has made debugging an issue extremely difficult, which is the opposite of the intention of this package. This is my suggestion to fix that.

@TomJGooding
Copy link
Contributor

I cannot control the fact that rich.traceback.install has been called somewhere.

But why should the onus be on Rich rather than whatever dependency has installed the traceback handler?

How can I reliably find that?

I have no idea what dependencies you have installed. I'm just suggesting that perhaps your first port of call should be whatever dependency that's using Rich, rather than going straight to Rich with the issue.

@matthewfranglen
Copy link
Author

Rich is the dependency that is producing the problematic output.

@willmcgugan
Copy link
Collaborator

I'm reluctant to impose non-standard environment variables on apps. It really isn't the place of a library to do that.

I would petition the maintainer of the library that enabled the tracebacks to add that env var.

Or, you could disable the exception hook. This will restore the Python default:

sys.excepthook = sys.__excepthook__

Alternatively, call traceback.install(...) again with new settings.

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

3 participants