aboutsummaryrefslogtreecommitdiffstats
path: root/run_exps.py
diff options
context:
space:
mode:
Diffstat (limited to 'run_exps.py')
-rwxr-xr-xrun_exps.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/run_exps.py b/run_exps.py
index 6873877..4a2d8ab 100755
--- a/run_exps.py
+++ b/run_exps.py
@@ -27,15 +27,24 @@ class InvalidConfig(Exception):
27 self.results = results 27 self.results = results
28 28
29 def __str__(self): 29 def __str__(self):
30 rstr = "'%s' - wanted: '%s', found: %s" 30 rstr = "'%s'%swanted: '%s', found: %s"
31 result = [rstr % (r.actual, r.param, r.wanted) for r in self.results] 31 messages = []
32 return "Invalid kernel configuration\n" + result.join("\n") 32 for r in self.results:
33 # For pretty alignment
34 tabs = (3 - len(r.param)/8)
35 messages += [rstr % (r.param, '\t'*tabs, r.wanted, r.actual)]
36
37 return "Invalid kernel configuration " +\
38 "(ignore configuration with -i option).\n" + "\n".join(messages)
33 39
34def parse_args(): 40def parse_args():
35 parser = OptionParser("usage: %prog [options] [sched_file]... [exp_dir]...") 41 parser = OptionParser("usage: %prog [options] [sched_file]... [exp_dir]...")
36 42
37 parser.add_option('-s', '--scheduler', dest='scheduler', 43 parser.add_option('-s', '--scheduler', dest='scheduler',
38 help='scheduler for all experiments') 44 help='scheduler for all experiments')
45 parser.add_option('-i', '--ignore-environment', dest='ignore',
46 action='store_true', default=False,
47 help='run experiments even in invalid environments ')
39 parser.add_option('-d', '--duration', dest='duration', type='int', 48 parser.add_option('-d', '--duration', dest='duration', type='int',
40 help='duration (seconds) of tasks') 49 help='duration (seconds) of tasks')
41 parser.add_option('-o', '--out-dir', dest='out_dir', 50 parser.add_option('-o', '--out-dir', dest='out_dir',
@@ -87,7 +96,7 @@ def fix_paths(schedule, exp_dir, sched_file):
87 if os.path.exists(abspath): 96 if os.path.exists(abspath):
88 args = args.replace(arg, abspath) 97 args = args.replace(arg, abspath)
89 break 98 break
90 elif re.match(r'.*\w+\.\w+', arg): 99 elif re.match(r'.*\w+\.[a-zA-Z]\w*', arg):
91 print("WARNING: non-existent file '%s' may be referenced:\n\t%s" 100 print("WARNING: non-existent file '%s' may be referenced:\n\t%s"
92 % (arg, sched_file)) 101 % (arg, sched_file))
93 102
@@ -108,9 +117,10 @@ def verify_environment(kernel, copts):
108 results += [ConfigResult(param, wanted, actual)] 117 results += [ConfigResult(param, wanted, actual)]
109 118
110 if results: 119 if results:
111 raise InvalidKernel(results) 120 raise InvalidConfig(results)
112 121
113def load_experiment(sched_file, scheduler, duration, param_file, out_dir): 122def load_experiment(sched_file, scheduler, duration,
123 param_file, out_dir, ignore):
114 if not os.path.isfile(sched_file): 124 if not os.path.isfile(sched_file):
115 raise IOError("Cannot find schedule file: %s" % sched_file) 125 raise IOError("Cannot find schedule file: %s" % sched_file)
116 126
@@ -146,7 +156,8 @@ def load_experiment(sched_file, scheduler, duration, param_file, out_dir):
146 156
147 fix_paths(schedule, os.path.split(sched_file)[0], sched_file) 157 fix_paths(schedule, os.path.split(sched_file)[0], sched_file)
148 158
149 verify_environment(kernel, copts) 159 if not ignore:
160 verify_environment(kernel, copts)
150 161
151 run_exp(exp_name, schedule, scheduler, kernel, duration, work_dir, out_dir) 162 run_exp(exp_name, schedule, scheduler, kernel, duration, work_dir, out_dir)
152 163
@@ -251,7 +262,8 @@ def main():
251 path = "%s/%s" % (path, opts.sched_file) 262 path = "%s/%s" % (path, opts.sched_file)
252 263
253 try: 264 try:
254 load_experiment(path, scheduler, duration, param_file, out_dir) 265 load_experiment(path, scheduler, duration, param_file,
266 out_dir, opts.ignore)
255 succ += 1 267 succ += 1
256 except ExperimentDone: 268 except ExperimentDone:
257 done += 1 269 done += 1