Skip to content

Commit

Permalink
Merge pull request #3201 from vkarak/bugfix/perflog-compat-headers
Browse files Browse the repository at this point in the history
[bugfix] Fix perflog header formatting when `perflog_compat` is used
  • Loading branch information
vkarak committed May 24, 2024
2 parents 4d8753a + e1003e8 commit 428912c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion reframe/core/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def __init__(self, prefix, mode='a', encoding=None, fmt=None,
# Format specifiers
self.__fmt = fmt
self.__perffmt = perffmt
self.__attr_patt = re.compile(r'\%\((.*?)\)s(.)?')
self.__attr_patt = re.compile(r'\%\((.*?)\)s(.*?(?=%|$))?')
self.__ignore_keys = set(ignore_keys) if ignore_keys else set()

def __generate_header(self, record):
Expand Down
26 changes: 17 additions & 9 deletions unittests/test_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,13 +1291,10 @@ def test_perf_logging_multiline(make_runner, make_exec_ctx, perf_test,
config_perflog, tmp_path):
make_exec_ctx(
config_perflog(
fmt=(
'%(check_job_completion_time)s,%(version)s,'
'%(check_display_name)s,%(check_system)s,'
'%(check_partition)s,%(check_environ)s,'
'%(check_jobid)s,%(check_result)s,'
'%(check_perf_var)s=%(check_perf_value)s,%(check_perf_unit)s'
),
fmt=('%(check_job_completion_time)s|reframe %(version)s|'
'%(check_name)s|%(check_perf_var)s=%(check_perf_value)s|'
'ref=%(check_perf_ref)s (l=%(check_perf_lower_thres)s, '
'u=%(check_perf_upper_thres)s)|%(check_perf_unit)s'),
logging_opts={'perflog_compat': True}
)
)
Expand All @@ -1315,8 +1312,19 @@ def test_perf_logging_multiline(make_runner, make_exec_ctx, perf_test,
# assert that the emitted lines are correct
with open(logfile) as fp:
lines = fp.readlines()
assert ',perf0=100.0,unit0' in lines[1]
assert ',perf1=50.0,unit1' in lines[2]

version = osext.reframe_version()
assert lines[0] == ('job_completion_time|reframe version|name|'
'perf_var=perf_value|ref=perf_ref '
'(l=perf_lower_thres, u=perf_upper_thres)|perf_unit\n')
assert lines[1].endswith(
f'|reframe {version}|_MyPerfTest|'
f'perf0=100.0|ref=0 (l=null, u=null)|unit0\n'
)
assert lines[2].endswith(
f'|reframe {version}|_MyPerfTest|'
f'perf1=50.0|ref=0 (l=null, u=null)|unit1\n'
)


def test_perf_logging_lazy(make_runner, make_exec_ctx, lazy_perf_test,
Expand Down

0 comments on commit 428912c

Please sign in to comment.