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

Merged
merged 4 commits into from
Nov 22, 2024

Conversation

vaqxai
Copy link
Contributor

@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
Contributor 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?

@thewhaleking
Copy link
Contributor

No response from OP after two weeks. Closing. Can be re-opened if still needed.

@thewhaleking thewhaleking reopened this Nov 22, 2024
@thewhaleking thewhaleking changed the base branch from master to staging November 22, 2024 17:26
Copy link
Contributor

@roman-opentensor roman-opentensor left a comment

Choose a reason for hiding this comment

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

I tested this. Works well for me.

@roman-opentensor roman-opentensor merged commit d6d6f7f into opentensor:staging Nov 22, 2024
26 checks passed
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.

ANSI Escape Sequences do not work under PM2 in version of bittensor older than 6.9.4
3 participants