-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Update rich_progress.py #18505
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
Update rich_progress.py #18505
Conversation
Adapts the color of progress bar according to the color of system background
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general, thanks for working on it. A few tests will need updating:
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_metrics_format[.3f] - TypeError: __init__() got an unexpected keyword argument 'metrics_format'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_keyboard_interrupt - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_metrics_format[.3e] - TypeError: __init__() got an unexpected keyword argument 'metrics_format'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_correct_value_epoch_end - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar[dataset0] - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_custom_theme - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_leave[False-3] - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_configure_columns - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_num_sanity_val_steps[5] - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_counter_with_val_check_interval - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_can_be_pickled - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_reset_bars - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_leave[True-0] - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_with_refresh_rate[1-2-3-6] - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_with_refresh_rate[7-6-6-3] - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_metric_display_task_id - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar[dataset1] - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_with_refresh_rate[1-0-0-0] - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_with_refresh_rate[3-5-0-2] - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_with_refresh_rate[3-1-1-3] - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_with_refresh_rate[3-6-6-5] - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_metrics_fast_dev_run - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_with_refresh_rate[3-5-2-4] - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_num_sanity_val_steps[1] - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_with_refresh_rate[4-6-6-5] - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_with_refresh_rate[6-5-2-3] - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_metrics_theme_update - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_format'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_with_refresh_rate[3-1-0-1] - AttributeError: 'RichProgressBarTheme' object has no attribute 'metrics_text_delimiter'
FAILED callbacks/progress/test_rich_progress_bar.py::test_rich_progress_bar_colab_light_theme_update - AssertionError: assert 'default' == 'black'
- black
+ default
= 29 failed, 2750 passed, 446 skipped, 8 xfailed, 3809 warnings in 526.73s (0:08:46) =
You can run them locally like so
pip install -r requirements/pytorch/test.txt
py.test -v tests/tests_pytorch/callbacks/progress/test_rich_progress_bar.py
@staticmethod | ||
def detect_color_system() -> str: | ||
console = Console() | ||
return console.color_system |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we make this a proper function?
Is this the recommended way how users should implement their themes with rich?
|
GitGuardian id | Secret | Commit | Filename | |
---|---|---|---|---|
- | Generic High Entropy Secret | 78fa3af | tests/tests_app/utilities/test_login.py | View secret |
- | Base64 Basic Authentication | 78fa3af | tests/tests_app/utilities/test_login.py | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
Our GitHub checks need improvements? Share your feedbacks!
Adapts the color of progress bar according to the color of system background
What does this PR do?
Implemented RichProgressBarTheme with a new feature to detect the terminal background color and adjust the styles based on it. The terminal background color is detected using the Console class from the rich library. If the terminal supports truecolor, the TERMINAL_BG_COLOR environment variable is checked, otherwise, it is assumed to be a dark theme.
This implementation allows the RichProgressBar to be visible by default in both light and dark themes without requiring users to modify the theme.
Fixes #17118
Note: I am a beginner in open source, and haven't contributed to big codebases yet, if there is any issue please let me know
Before submitting
PR review
Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:
Reviewer checklist
📚 Documentation preview 📚: https://pytorch-lightning--18505.org.readthedocs.build/en/18505/