From 750c96ce115fb069344eae4797c7394c39c58379 Mon Sep 17 00:00:00 2001 From: Hank Wikle Date: Tue, 20 May 2025 10:15:16 -0600 Subject: [PATCH 1/7] Add 'key_results' section to test_config --- lib/pavilion/test_config/file_format.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/pavilion/test_config/file_format.py b/lib/pavilion/test_config/file_format.py index 83c4c813f..e2fc4cc7d 100644 --- a/lib/pavilion/test_config/file_format.py +++ b/lib/pavilion/test_config/file_format.py @@ -858,6 +858,12 @@ class TestConfigLoader(yc.YamlConfigLoader): "strings). Other result values (including those " "from result parsers and other evaluations are " "available to reference as variables."), + yc.ListElem( + 'key_results', + sub_elem=yc.StrElem(), + help_text="The list of result keys that should be considered " + "'key results'. These results appear automatically " + "when running 'pav results'.") ModuleWrapperCatElem( 'module_wrappers', help_text="Whenever the given module[/version] is asked for in the 'build.modules' " From 440725015a39000993f637ef3e4467df6a3e3b32 Mon Sep 17 00:00:00 2001 From: Hank Wikle Date: Tue, 20 May 2025 12:28:46 -0600 Subject: [PATCH 2/7] Fix missing comma --- lib/pavilion/test_config/file_format.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pavilion/test_config/file_format.py b/lib/pavilion/test_config/file_format.py index e2fc4cc7d..ddc8ea37a 100644 --- a/lib/pavilion/test_config/file_format.py +++ b/lib/pavilion/test_config/file_format.py @@ -863,7 +863,7 @@ class TestConfigLoader(yc.YamlConfigLoader): sub_elem=yc.StrElem(), help_text="The list of result keys that should be considered " "'key results'. These results appear automatically " - "when running 'pav results'.") + "when running 'pav results'."), ModuleWrapperCatElem( 'module_wrappers', help_text="Whenever the given module[/version] is asked for in the 'build.modules' " From 913e4da264c665aa8b4d42cea104bb04d0d3a415 Mon Sep 17 00:00:00 2001 From: Hank Wikle Date: Tue, 20 May 2025 13:06:40 -0600 Subject: [PATCH 3/7] Initial version of key_results --- lib/pavilion/commands/result.py | 7 +++++++ lib/pavilion/test_run/test_run.py | 1 + 2 files changed, 8 insertions(+) diff --git a/lib/pavilion/commands/result.py b/lib/pavilion/commands/result.py index cdc8b85d1..4acfd1a6f 100644 --- a/lib/pavilion/commands/result.py +++ b/lib/pavilion/commands/result.py @@ -218,11 +218,17 @@ def run(self, pav_cfg, args): else: fields = self.key_fields(args) flat_results = [] + key_results = set() all_passed = True for rslt in results: flat_results.append(utils.flatten_dictionary(rslt)) if rslt['result'] != TestRun.PASS: all_passed = False + + key_results = key_results.union(set(rslt['key_results'])) + + fields += key_results + field_info = { 'created': {'transform': output.get_relative_timestamp}, 'started': {'transform': output.get_relative_timestamp}, @@ -269,6 +275,7 @@ def run(self, pav_cfg, args): else: flat_sorted_results = utils.sort_table(args.sort_by, flat_results) + print(f"Fields: {fields}") title_str=f"Test Results: {serieses}." output.draw_table( outfile=self.outfile, diff --git a/lib/pavilion/test_run/test_run.py b/lib/pavilion/test_run/test_run.py index 714d210b5..178f90878 100644 --- a/lib/pavilion/test_run/test_run.py +++ b/lib/pavilion/test_run/test_run.py @@ -945,6 +945,7 @@ def gather_results(self, run_result: int, regather: bool = False, results = result.base_results(self) results['return_value'] = run_result + results['key_results'] = self.config.get('key_results', []) result_log("Base results:") result_log.indent(pprint.pformat(results)) From 13dbca6c0349e4ba1c0115750d15fcbbd5e3ffb8 Mon Sep 17 00:00:00 2001 From: Hank Wikle Date: Tue, 20 May 2025 14:21:52 -0600 Subject: [PATCH 4/7] Fix when no key results specified --- lib/pavilion/commands/result.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pavilion/commands/result.py b/lib/pavilion/commands/result.py index 4acfd1a6f..12e17a5bb 100644 --- a/lib/pavilion/commands/result.py +++ b/lib/pavilion/commands/result.py @@ -225,7 +225,10 @@ def run(self, pav_cfg, args): if rslt['result'] != TestRun.PASS: all_passed = False - key_results = key_results.union(set(rslt['key_results'])) + key_results = key_results.union(set(rslt.get('key_results', []))) + + for k in key_results: + if k not in fields += key_results From f995c52290779299c04ad1cc014bfcb31c8718f2 Mon Sep 17 00:00:00 2001 From: Hank Wikle Date: Tue, 20 May 2025 14:24:24 -0600 Subject: [PATCH 5/7] Fix bad code --- lib/pavilion/commands/result.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/pavilion/commands/result.py b/lib/pavilion/commands/result.py index 12e17a5bb..7b14d5cd0 100644 --- a/lib/pavilion/commands/result.py +++ b/lib/pavilion/commands/result.py @@ -227,9 +227,6 @@ def run(self, pav_cfg, args): key_results = key_results.union(set(rslt.get('key_results', []))) - for k in key_results: - if k not in - fields += key_results field_info = { From 5a92c8e33aa0fddc47bb95c3a6e1b6d31461f4a1 Mon Sep 17 00:00:00 2001 From: Hank Wikle Date: Tue, 20 May 2025 14:25:26 -0600 Subject: [PATCH 6/7] Remove leftover print statement --- lib/pavilion/commands/result.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pavilion/commands/result.py b/lib/pavilion/commands/result.py index 7b14d5cd0..f15bb3780 100644 --- a/lib/pavilion/commands/result.py +++ b/lib/pavilion/commands/result.py @@ -275,7 +275,6 @@ def run(self, pav_cfg, args): else: flat_sorted_results = utils.sort_table(args.sort_by, flat_results) - print(f"Fields: {fields}") title_str=f"Test Results: {serieses}." output.draw_table( outfile=self.outfile, From 9cd2740d69d6a0fb724ff07fefd9259318b55fb7 Mon Sep 17 00:00:00 2001 From: Hank Wikle Date: Tue, 20 May 2025 14:56:49 -0600 Subject: [PATCH 7/7] Add unit test for key results --- test/tests/result_tests.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/tests/result_tests.py b/test/tests/result_tests.py index 4d6520cce..f82be1c97 100644 --- a/test/tests/result_tests.py +++ b/test/tests/result_tests.py @@ -1123,3 +1123,38 @@ def test_flatten_results(self): self.assertEqual(flattened, answer) self.assertEqual(unflattened, answer) + + def test_key_results(self): + """Check that specifying key results causes those values to show up + in the results table.""" + + cfg = self._quick_test_cfg() + + cfg['run']['cmds'] = [ + 'echo hello' + ] + cfg['result_parse']['regex'] = { + 'hello': { + 'regex': 'hello', + } + } + cfg['key_results'] = ['hello'] + + test = self._quick_test(cfg, name="key_results_test") + run_result = test.run() + results = test.gather_results(run_result) + test.save_results(results) + + result_cmd = commands.get_command('result') + result_cmd.silence() + + arg_parser = arguments.get_parser() + res_args = arg_parser.parse_args(("result", test.full_id)) + + result_cmd.run(self.pav_cfg, res_args) + cmd_out, cmd_err = result_cmd.clear_output() + + lines = cmd_out.split('\n') + + self.assertIn("Hello", lines[2]) + self.assertIn("hello", lines[4])