From 5d4e52481d549e27d25f3ab54d4ea5864b3bec48 Mon Sep 17 00:00:00 2001 From: Christopher Spinrath <christopher.spinrath@univ-grenoble-alpes.fr> Date: Wed, 30 Apr 2025 14:48:02 +0200 Subject: [PATCH] Support variable substitutions in variable definitions --- run-exp.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/run-exp.py b/run-exp.py index 83e3103..6eda873 100755 --- a/run-exp.py +++ b/run-exp.py @@ -241,11 +241,24 @@ def main(config_file, global_timeout, dry_run): print(f"> and {c.repetitions} repetitions") print() - variable_map = {v.name: v.evaluate({}) for v in c.variables} - value_combinations = itertools.product(*variable_map.values()) - run_values = [dict(zip(variable_map.keys(), vals)) for vals in value_combinations] + # we precompute all variable values to be able to abort early in case of a problem, + # for instance, if a file does not exist + variable_maps = [{}] - for variables in run_values: + for variable in c.variables: + updated_variable_maps = [] + + for variable_map in variable_maps: + values = variable.evaluate(variable_map) + + for value in values: + updated_map = variable_map.copy() + updated_map[variable.name] = value + updated_variable_maps.append(updated_map) + + variable_maps = updated_variable_maps + + for variables in variable_maps: print() print("Running tasks with variable map: ") print(variables) -- GitLab