From 5af4be6a9e8311e158c8441907e5851336763ff1 Mon Sep 17 00:00:00 2001 From: Jean Luca Bez Date: Fri, 13 Jan 2023 11:23:21 -0800 Subject: [PATCH 1/2] Include light theme option for export data --- drishti/main.py | 55 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/drishti/main.py b/drishti/main.py index 8dad467..349dff3 100644 --- a/drishti/main.py +++ b/drishti/main.py @@ -21,14 +21,13 @@ from rich.text import Text from rich.syntax import Syntax from rich.panel import Panel +from rich.terminal_theme import TerminalTheme from rich.terminal_theme import MONOKAI from subprocess import call from packaging import version -console = Console(record=True) - RECOMMENDATIONS = 0 HIGH = 1 WARN = 2 @@ -133,6 +132,21 @@ help='Export the report as an SVG image' ) +parser.add_argument( + '--light', + default=False, + action='store_true', + dest='export_theme_light', + help='Use a light theme for the report when generating files' +) + +parser.add_argument( + '--size', + default=False, + dest='export_size', + help='Console width used for the report and generated files' +) + parser.add_argument( '--verbose', default=False, @@ -167,9 +181,14 @@ args = parser.parse_args() +if args.export_size: + console = Console(record=True, width=int(args.export_size)) +else: + console = Console(record=True) csv_report = [] + def validate_thresholds(): """ Validate thresholds defined by the user. @@ -1514,10 +1533,38 @@ def main(): ) ) + if args.export_theme_light: + export_theme = TerminalTheme( + (255, 255, 255), + (0, 0, 0), + [ + (26, 26, 26), + (244, 0, 95), + (152, 224, 36), + (253, 151, 31), + (157, 101, 255), + (244, 0, 95), + (88, 209, 235), + (120, 120, 120), + (98, 94, 76), + ], + [ + (244, 0, 95), + (152, 224, 36), + (224, 213, 97), + (157, 101, 255), + (244, 0, 95), + (88, 209, 235), + (246, 246, 239), + ], + ) + else: + export_theme = MONOKAI + if args.export_html: console.save_html( '{}.html'.format(args.darshan), - theme=MONOKAI, + theme=export_theme, clear=False ) @@ -1525,7 +1572,7 @@ def main(): console.save_svg( '{}.svg'.format(args.darshan), title='Drishti', - theme=MONOKAI, + theme=export_theme, clear=False ) From 313c4fa065e5538cabe8d2dafec29eab98fba4cf Mon Sep 17 00:00:00 2001 From: Jean Luca Bez Date: Tue, 17 Jan 2023 13:21:00 -0600 Subject: [PATCH 2/2] Fix support with py-darshan 3.4.2 --- drishti/main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drishti/main.py b/drishti/main.py index 349dff3..922ebff 100644 --- a/drishti/main.py +++ b/drishti/main.py @@ -1442,8 +1442,13 @@ def main(): insights_end_time = time.time() - job_start = datetime.datetime.fromtimestamp(job['job']['start_time'], datetime.timezone.utc) - job_end = datetime.datetime.fromtimestamp(job['job']['end_time'], datetime.timezone.utc) + # Version 3.4.2 of py-darshan changed the contents on what is reported in 'job' + if 'start_time' in job['job']: + job_start = datetime.datetime.fromtimestamp(job['job']['start_time'], datetime.timezone.utc) + job_end = datetime.datetime.fromtimestamp(job['job']['end_time'], datetime.timezone.utc) + else: + job_start = datetime.datetime.fromtimestamp(job['job']['start_time_sec'], datetime.timezone.utc) + job_end = datetime.datetime.fromtimestamp(job['job']['end_time_sec'], datetime.timezone.utc) console.print()