Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs/manpage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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.
Expand Down
17 changes: 11 additions & 6 deletions reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,19 @@ 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):
self.__logger.error(f'{self.__message}: {exc_val}')
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)


Expand Down Expand Up @@ -631,6 +634,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',
Expand Down Expand Up @@ -997,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
Expand Down
13 changes: 12 additions & 1 deletion reframe/frontend/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,15 @@ def table(self, data, **kwargs):

kwargs.setdefault('headers', 'firstrow')
kwargs.setdefault('tablefmt', tablefmt)
self.info(tabulate(data, **kwargs))
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(',')
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))
9 changes: 9 additions & 0 deletions unittests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down