From 5c26ead814a368019bcf2ec41c4374799b10b0a0 Mon Sep 17 00:00:00 2001 From: Tribhuvan Mishra <74012568+Tribhuvan0@users.noreply.github.com> Date: Fri, 8 Sep 2023 11:17:35 +0530 Subject: [PATCH 1/2] Update rich_progress.py Adapts the color of progress bar according to the color of system background --- .../callbacks/progress/rich_progress.py | 48 +++++++++++++++---- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/src/lightning/pytorch/callbacks/progress/rich_progress.py b/src/lightning/pytorch/callbacks/progress/rich_progress.py index 1d9914a53824f..a0d1218f509fb 100644 --- a/src/lightning/pytorch/callbacks/progress/rich_progress.py +++ b/src/lightning/pytorch/callbacks/progress/rich_progress.py @@ -206,17 +206,45 @@ class RichProgressBarTheme: https://rich.readthedocs.io/en/stable/style.html """ + @staticmethod + def detect_color_system() -> str: + console = Console() + return console.color_system + + color_system = detect_color_system.__func__() + + # Default colors for each color system + default_colors = { + "truecolor": { + "progress_bar": "bright_blue", + "time": "bright_cyan", + "processing_speed": "bright_yellow", + }, + "256": { + "progress_bar": "color51", + "time": "color45", + "processing_speed": "color227", + }, + "default": { + "progress_bar": "blue", + "time": "cyan", + "processing_speed": "yellow", + }, + } + + # Apply specific colors based on the detected color system + colors = default_colors.get(color_system, default_colors["default"]) + + description: Union[str, Style] = "default" + progress_bar: Union[str, Style] = colors["progress_bar"] + progress_bar_finished: Union[str, Style] = colors["progress_bar"] + progress_bar_pulse: Union[str, Style] = colors["progress_bar"] + batch_progress: Union[str, Style] = "default" + time: Union[str, Style] = colors["time"] + processing_speed: Union[str, Style] = colors["processing_speed"] + metrics: Union[str, Style] = "default" + - description: Union[str, Style] = "white" - progress_bar: Union[str, Style] = "#6206E0" - progress_bar_finished: Union[str, Style] = "#6206E0" - progress_bar_pulse: Union[str, Style] = "#6206E0" - batch_progress: Union[str, Style] = "white" - time: Union[str, Style] = "grey54" - processing_speed: Union[str, Style] = "grey70" - metrics: Union[str, Style] = "white" - metrics_text_delimiter: str = " " - metrics_format: str = ".3f" class RichProgressBar(ProgressBar): From ca8ab73c3d8b94a0fac6d7840340f3a3165d9a77 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 8 Sep 2023 05:51:37 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/lightning/pytorch/callbacks/progress/rich_progress.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lightning/pytorch/callbacks/progress/rich_progress.py b/src/lightning/pytorch/callbacks/progress/rich_progress.py index a0d1218f509fb..bb9d15fbbc481 100644 --- a/src/lightning/pytorch/callbacks/progress/rich_progress.py +++ b/src/lightning/pytorch/callbacks/progress/rich_progress.py @@ -206,6 +206,7 @@ class RichProgressBarTheme: https://rich.readthedocs.io/en/stable/style.html """ + @staticmethod def detect_color_system() -> str: console = Console() @@ -245,8 +246,6 @@ def detect_color_system() -> str: metrics: Union[str, Style] = "default" - - class RichProgressBar(ProgressBar): """Create a progress bar with `rich text formatting `_.