diff --git a/run-exp.py b/run-exp.py index 1a26376f3b0a4d5f4d8aa3f14e42d5b0083e2ed6..35f15b6ed8b7e221d6f94bb7372719ed7bd2cf7f 100755 --- a/run-exp.py +++ b/run-exp.py @@ -37,15 +37,24 @@ class Variable: return cls.new_scalar(name, value_config) var_type = value_config["type"] - assert var_type in ["file"], "Unsupported variable type." + assert var_type in ["file", "range"], "Unsupported variable type." - directory = pathlib.Path(value_config["directory"]) - assert directory.exists() and directory.is_dir() + if var_type == "file": + directory = pathlib.Path(value_config["directory"]) + assert directory.exists() and directory.is_dir() - values = list(directory.iterdir()) + values = list(directory.iterdir()) - if value_config.get("basename", False): - values = [v.name for v in values] + if value_config.get("basename", False): + values = [v.name for v in values] + + if var_type == "range": + assert "max" in value_config, f"Missing \"max\" value for range variable \"{name}\"" + upper = value_config["max"] + lower = value_config.get("min", 0) + step = value_config.get("step", 1) + + values = list(range(lower, upper + 1, step)) return cls.new_multi_valued(name, values)