Skip to content
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

[enhancement] Various enhancements to the results DB feature #3283

Merged
merged 15 commits into from
Oct 23, 2024
Merged
233 changes: 146 additions & 87 deletions docs/manpage.rst

Large diffs are not rendered by default.

126 changes: 63 additions & 63 deletions docs/tutorial.rst

Large diffs are not rendered by default.

60 changes: 29 additions & 31 deletions reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,20 +401,20 @@ def main():
'for the selected tests and exit'),
)
action_options.add_argument(
'--delete-stored-session', action='store', metavar='UUID',
help='Delete stored session'
'--delete-stored-sessions', action='store', metavar='QUERY',
help='Delete stored sessions'
)
action_options.add_argument(
'--describe', action='store_true',
help='Give full details on the selected tests'
)
action_options.add_argument(
'--describe-stored-session', action='store', metavar='UUID',
'--describe-stored-sessions', action='store', metavar='QUERY',
help='Get detailed session information in JSON'
)
action_options.add_argument(
'--describe-stored-testcases', action='store',
metavar='SESSION_UUID|PERIOD',
metavar='QUERY',
help='Get detailed test case information in JSON'
)
action_options.add_argument(
Expand All @@ -434,12 +434,11 @@ def main():
)
action_options.add_argument(
'--list-stored-sessions', nargs='?', action='store',
const='now-1w:now', metavar='PERIOD', help='List stored sessions'
const='now-1w:now', metavar='QUERY', help='List stored sessions'
)
action_options.add_argument(
'--list-stored-testcases', action='store',
metavar='SESSION_UUID|PERIOD',
help='List stored testcases by session or time period'
'--list-stored-testcases', action='store', metavar='QUERY',
help='List performance info for stored testcases'
)
action_options.add_argument(
'-l', '--list', nargs='?', const='T', choices=['C', 'T'],
Expand Down Expand Up @@ -617,7 +616,7 @@ def main():
'(default: "now:now/last:+job_nodelist/+result")')
)
reporting_options.add_argument(
'--session-extras', action='store', metavar='KV_DATA',
'--session-extras', action='append', metavar='KV_DATA',
help='Annotate session with custom key/value data'
)

Expand All @@ -641,15 +640,10 @@ def main():
envvar='RFM_SYSTEM'
)
misc_options.add_argument(
'--table-format', choices=['csv', 'plain', 'pretty'],
'--table-format', choices=['csv', 'plain', 'outline', 'grid'],
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 @@ -831,7 +825,7 @@ def restrict_logging():
if (options.show_config or
options.detect_host_topology or
options.describe or
options.describe_stored_session or
options.describe_stored_sessions or
options.describe_stored_testcases):
logging.getlogger().setLevel(logging.ERROR)
return True
Expand Down Expand Up @@ -983,29 +977,29 @@ def restrict_logging():
if options.list_stored_sessions:
with exit_gracefully_on_error('failed to retrieve session data',
printer):
time_period = options.list_stored_sessions
if time_period == 'all':
time_period = None
spec = options.list_stored_sessions
if spec == 'all':
spec = '19700101T0000+0000:now'

printer.table(reporting.session_data(time_period))
printer.table(reporting.session_data(spec))
sys.exit(0)

if options.list_stored_testcases:
namepatt = '|'.join(options.names)
with exit_gracefully_on_error('failed to retrieve test case data',
printer):
printer.table(reporting.testcase_data(
options.list_stored_testcases, namepatt
options.list_stored_testcases, namepatt, options.filter_expr
))
sys.exit(0)

if options.describe_stored_session:
if options.describe_stored_sessions:
# Restore logging level
printer.setLevel(logging.INFO)
with exit_gracefully_on_error('failed to retrieve session data',
printer):
printer.info(jsonext.dumps(reporting.session_info(
options.describe_stored_session
options.describe_stored_sessions
), indent=2))
sys.exit(0)

Expand All @@ -1020,11 +1014,12 @@ def restrict_logging():
), indent=2))
sys.exit(0)

if options.delete_stored_session:
session_uuid = options.delete_stored_session
if options.delete_stored_sessions:
query = options.delete_stored_sessions
with exit_gracefully_on_error('failed to delete session', printer):
reporting.delete_session(session_uuid)
printer.info(f'Session {session_uuid} deleted successfully.')
for uuid in reporting.delete_sessions(query):
printer.info(f'Session {uuid} deleted successfully.')

sys.exit(0)

if options.performance_compare:
Expand All @@ -1033,7 +1028,9 @@ def restrict_logging():
printer):
printer.table(
reporting.performance_compare(options.performance_compare,
namepatt=namepatt)
None,
namepatt,
options.filter_expr)
)
sys.exit(0)

Expand Down Expand Up @@ -1598,9 +1595,10 @@ def module_unuse(*paths):
if options.session_extras:
# Update report's extras
extras = {}
for arg in options.session_extras.split(','):
k, v = arg.split('=', maxsplit=1)
extras[k] = v
for sess in options.session_extras:
for arg in sess.split(','):
k, v = arg.split('=', maxsplit=1)
extras[k] = v

report.update_extras(extras)

Expand Down
23 changes: 4 additions & 19 deletions reframe/frontend/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,29 +269,14 @@ def table(self, data, **kwargs):
# Map our options to tabulate
if table_format == 'plain':
tablefmt = 'plain'
elif table_format == 'pretty':
elif table_format == 'outline':
tablefmt = 'mixed_outline'
elif table_format == 'grid':
tablefmt = 'mixed_grid'
else:
raise ValueError(f'invalid table format: {table_format}')

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(',')
colidx = [i for i, col in enumerate(data[0])
if col not in hide_columns]

def _access(seq, i, default=None):
# Safe access of i-th element of a sequence
try:
return seq[i]
except IndexError:
return default

tab_data = [[_access(rec, col) for col in colidx] for rec in data]
else:
tab_data = data

self.info(tabulate(tab_data, **kwargs))
self.info(tabulate(data, **kwargs))
Loading
Loading