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

Don't strip ANSI from stdout (fixes #2365) #2366

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vaqxai
Copy link

@vaqxai vaqxai commented Oct 21, 2024

  • Until now ANSI was stripped from stdout if bittensor was not running within a TTY (like in PM2) by colorama when it was intialized
  • This caused colored output to be broken under PM2 (and other process managers which do not give a TTY do bittensor/python
  • Bittensor posseses its own file logger, which makes this behavior unnecessary and unwanted.
  • This patch disables that behavior.

Where ANSI Stripping takes place in colorama: https://github.com/tartley/colorama/blob/136808718af8b9583cb2eed1756ed6972eda4975/colorama/ansitowin32.py#L102

Bittensor call to colorama which indirectly breaks colors in terminal output in PM2:

init(autoreset=True)

Fix for issue #2365

- Until now ANSI was stripped from stdout if bittensor was not running within a TTY (like in PM2)
- This caused colored output to be broken under PM2 (and other process managers which do not give a TTY do bittensor/python
- Bittensor posseses its own file logger, which makes this behavior unnecessary and unwanted.
- This patch disables that behavior.
@vaqxai
Copy link
Author

vaqxai commented Oct 21, 2024

I found out that using strip=False introduces arbitrary newlines, instead, wrap=False can be used, and everything works correctly.

Maybe this should be user-definable by some config parameter?

Only without output wrapping does terminal output under PM2 behave correctly.
@thewhaleking
Copy link
Contributor

Sorry, what is PM2?

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

Successfully merging this pull request may close these issues.

2 participants