From 33a09286354fd0258a36f42ef624a0e8866ad0d3 Mon Sep 17 00:00:00 2001 From: Antonio Paolillo Date: Thu, 29 Jan 2026 11:40:37 +0100 Subject: [PATCH 1/3] benchmark.py: Factor out pretty updates in method Signed-off-by: Antonio Paolillo --- benchkit/benchmark.py | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/benchkit/benchmark.py b/benchkit/benchmark.py index 31876490..578ac28f 100644 --- a/benchkit/benchmark.py +++ b/benchkit/benchmark.py @@ -11,7 +11,7 @@ import pathlib from multiprocessing import Barrier from subprocess import CalledProcessError -from typing import IO, Any, Dict, Iterable, List, Optional, Protocol, Tuple, Type +from typing import IO, Any, Dict, Iterable, List, Optional, Protocol, Tuple, Type, Sequence from benchkit.commandwrappers import CommandWrapper from benchkit.dependencies import check_dependencies @@ -918,6 +918,24 @@ def _temp_record_data_dir(self, record_data_dir: pathlib.Path): # never an absolute path. return self._temp_record_prefix() / f"./{record_data_dir}" + def _update_pretty_variables(self, experiment_results: Dict[str, Any]): + if self._pretty_variables: + for var_name in self._pretty_variables: + ugly2pretty = self._pretty_variables[var_name] + ugly_var_value = experiment_results.get(var_name) + + if not isinstance(ugly2pretty, dict): + # If the pretty variable is not a dict, assume it's the pretty column name + experiment_results[ugly2pretty] = ugly_var_value + continue + + pretty_var_value = ugly2pretty.get(ugly_var_value, ugly_var_value) + experiment_results[f"{var_name}_pretty"] = f'"{pretty_var_value}"' + # If __category__ is defined, also create a column with that name + category = ugly2pretty.get("__category__") + if category is not None: + experiment_results[category] = f'"{pretty_var_value}"' + def _run_single_run( self, record_parameters: Dict[str, Any], @@ -960,22 +978,7 @@ def _run_single_run( experiment_results.update(run_variables) experiment_results.update(other_variables) - if self._pretty_variables: - for var_name in self._pretty_variables: - ugly2pretty = self._pretty_variables[var_name] - ugly_var_value = experiment_results.get(var_name) - - if not isinstance(ugly2pretty, dict): - # If the pretty variable is not a dict, assume it's the pretty column name - experiment_results[ugly2pretty] = ugly_var_value - continue - - pretty_var_value = ugly2pretty.get(ugly_var_value, ugly_var_value) - experiment_results[f"{var_name}_pretty"] = f'"{pretty_var_value}"' - # If __category__ is defined, also create a column with that name - category = ugly2pretty.get("__category__") - if category is not None: - experiment_results[category] = f'"{pretty_var_value}"' + self._update_pretty_variables(experiment_results=experiment_results) experiment_results.update({"rep": run_id}) From 06dcfae89ceefc9c94472c39b3c383011ab802fa Mon Sep 17 00:00:00 2001 From: Antonio Paolillo Date: Thu, 29 Jan 2026 11:49:53 +0100 Subject: [PATCH 2/3] fix fmt Signed-off-by: Antonio Paolillo --- benchkit/benchmark.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchkit/benchmark.py b/benchkit/benchmark.py index 578ac28f..dba8a4cb 100644 --- a/benchkit/benchmark.py +++ b/benchkit/benchmark.py @@ -11,7 +11,7 @@ import pathlib from multiprocessing import Barrier from subprocess import CalledProcessError -from typing import IO, Any, Dict, Iterable, List, Optional, Protocol, Tuple, Type, Sequence +from typing import IO, Any, Dict, Iterable, List, Optional, Protocol, Sequence, Tuple, Type from benchkit.commandwrappers import CommandWrapper from benchkit.dependencies import check_dependencies From 18765c53a5b6bb08527a9c9de5d51e1ec78b3d58 Mon Sep 17 00:00:00 2001 From: Antonio Paolillo Date: Thu, 29 Jan 2026 12:06:22 +0100 Subject: [PATCH 3/3] Fix format Signed-off-by: Antonio Paolillo --- benchkit/benchmark.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchkit/benchmark.py b/benchkit/benchmark.py index dba8a4cb..f4496eea 100644 --- a/benchkit/benchmark.py +++ b/benchkit/benchmark.py @@ -11,7 +11,7 @@ import pathlib from multiprocessing import Barrier from subprocess import CalledProcessError -from typing import IO, Any, Dict, Iterable, List, Optional, Protocol, Sequence, Tuple, Type +from typing import IO, Any, Dict, Iterable, List, Optional, Protocol, Tuple, Type from benchkit.commandwrappers import CommandWrapper from benchkit.dependencies import check_dependencies