From a034e5c64ddfc2f937fb996126af9edbb4fdc462 Mon Sep 17 00:00:00 2001
From: Christopher Spinrath <christopher.spinrath@univ-grenoble-alpes.fr>
Date: Fri, 24 Jan 2025 00:09:18 +0100
Subject: [PATCH] Support flags for tasks which depend on (the presence of) a
 variable

---
 run-exp.py | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/run-exp.py b/run-exp.py
index 35f15b6..1645874 100755
--- a/run-exp.py
+++ b/run-exp.py
@@ -75,8 +75,22 @@ class Task:
         return self._work_dir
 
     def run(self, variables):
-        parameters = [p.format(**variables) for p in self._parameters]
-        args = [self._base_command] + parameters
+        args = [self._base_command]
+
+        for p in self._parameters:
+            if not isinstance(p, dict):
+                args.append(p.format(**variables))
+                continue
+
+            assert "value" in p, "An extended paramter has to contain a value field"
+
+            if "if-variable" in p:
+                v = p["if-variable"]
+
+                if v not in variables.keys() or (isinstance(variables[v], bool) and not variables[v]):
+                    continue  # skip
+
+            args.append(p["value"].format(**variables))
 
         # print()
         # print(f"pushd {self._work_dir}")
-- 
GitLab