From 414e17b7b802140b0b80cbe1f3db510e81b4faab Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Thu, 29 Aug 2024 13:54:33 +0200 Subject: [PATCH 1/3] New `--table-hide-columns` option --- docs/manpage.rst | 8 +++++++- reframe/frontend/cli.py | 5 +++++ reframe/frontend/printer.py | 12 +++++++++++- unittests/test_cli.py | 9 +++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/docs/manpage.rst b/docs/manpage.rst index 563017451..b5be5fd1f 100644 --- a/docs/manpage.rst +++ b/docs/manpage.rst @@ -1132,7 +1132,7 @@ Miscellaneous options .. option:: --table-format=csv|plain|pretty - Set the formatting of tabular output printed by options :option:`--performance-compare`, :option:`--performance-report` and the options controlling the stored sessions. + Set the formatting of tabular output printed by the options :option:`--performance-compare`, :option:`--performance-report` and the options controlling the stored sessions. The acceptable values are the following: @@ -1142,6 +1142,12 @@ Miscellaneous options .. versionadded:: 4.7 +.. option:: --table-hide-columns=COLUMNS + + Hide the specified comma-separated list of columns from the tabular output printed by the options :option:`--performance-compare`, :option:`--performance-report` and the options controlling the stored sessions. + + .. versionadded:: 4.7 + .. option:: --upgrade-config-file=OLD[:NEW] Convert the old-style configuration file ``OLD``, place it into the new file ``NEW`` and exit. diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index e4e3bd1f2..32eb96f80 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -631,6 +631,11 @@ def main(): help='Table formatting', envvar='RFM_TABLE_FORMAT', configvar='general/table_format' ) + misc_options.add_argument( + '--table-hide-columns', metavar='COLS', action='store', + help='Hide specific columns from the final table', + envvar='RFM_TABLE_HIDE_COLUMNS', configvar='general/table_hide_columns' + ) misc_options.add_argument( '-v', '--verbose', action='count', help='Increase verbosity level of output', diff --git a/reframe/frontend/printer.py b/reframe/frontend/printer.py index a8a88b91c..6cd4200ed 100644 --- a/reframe/frontend/printer.py +++ b/reframe/frontend/printer.py @@ -276,4 +276,14 @@ def table(self, data, **kwargs): kwargs.setdefault('headers', 'firstrow') kwargs.setdefault('tablefmt', tablefmt) - self.info(tabulate(data, **kwargs)) + hide_columns = rt.runtime().get_option('general/0/table_hide_columns') + if hide_columns and kwargs['headers'] == 'firstrow' and data: + hide_columns = hide_columns.split(',') + colidx = [i for i, col in enumerate(data[0]) + if col not in hide_columns] + + tab_data = [[rec[col] for col in colidx] for rec in data] + else: + tab_data = data + + self.info(tabulate(tab_data, **kwargs)) diff --git a/unittests/test_cli.py b/unittests/test_cli.py index c5f517819..13339e8d9 100644 --- a/unittests/test_cli.py +++ b/unittests/test_cli.py @@ -1298,6 +1298,15 @@ def assert_no_crash(returncode, stdout, stderr, exitcode=0): *run_reframe2(action=f'--describe-stored-testcases={uuid}') ) + # Check hiding of table column + stdout = assert_no_crash(*run_reframe2( + action=f'--list-stored-testcases={uuid}', + more_options=['--table-hide-columns=SysEnv,Nodelist,UUID'] + ))[1] + assert 'SysEnv' not in stdout + assert 'Nodelist' not in stdout + assert 'UUID' not in stdout + # List test cases by time period ts_start = session_json['session_info']['time_start'] assert_no_crash( From 92c4aa7784b8e32d11199381748b20f56aafdbab Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Thu, 29 Aug 2024 13:58:13 +0200 Subject: [PATCH 2/3] Do not align decimals on the dot --- reframe/frontend/printer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/reframe/frontend/printer.py b/reframe/frontend/printer.py index 6cd4200ed..e622ad77b 100644 --- a/reframe/frontend/printer.py +++ b/reframe/frontend/printer.py @@ -276,6 +276,7 @@ def table(self, data, **kwargs): kwargs.setdefault('headers', 'firstrow') kwargs.setdefault('tablefmt', tablefmt) + kwargs.setdefault('numalign', 'right') hide_columns = rt.runtime().get_option('general/0/table_hide_columns') if hide_columns and kwargs['headers'] == 'firstrow' and data: hide_columns = hide_columns.split(',') From a5a62eb34f2c35dc6122913b04a92d61e42cd6be Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Thu, 29 Aug 2024 14:34:12 +0200 Subject: [PATCH 3/3] Profile `performance_compare` + minor storage profiling improvements --- reframe/frontend/cli.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index 32eb96f80..fd6af2e03 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -218,9 +218,10 @@ def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): - logging.getprofiler().print_report(self.__logger.debug) if exc_type is SystemExit: # Allow users to exit inside the context manager + logging.getprofiler().exit_region() + logging.getprofiler().print_report(self.__logger.debug) return if isinstance(exc_val, self.__exceptions): @@ -228,6 +229,8 @@ def __exit__(self, exc_type, exc_val, exc_tb): self.__logger.verbose( ''.join(traceback.format_exception(exc_type, exc_val, exc_tb)) ) + logging.getprofiler().exit_region() + logging.getprofiler().print_report(self.__logger.debug) sys.exit(self.__exitcode) @@ -1002,15 +1005,12 @@ def restrict_logging(): if options.performance_compare: namepatt = '|'.join(options.names) - try: + with exit_gracefully_on_error('failed to generate performance report', + printer): printer.table( reporting.performance_compare(options.performance_compare, namepatt=namepatt) ) - except errors.ReframeError as err: - printer.error(f'failed to generate performance report: {err}') - sys.exit(1) - else: sys.exit(0) # Show configuration after everything is set up