diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-09-30 18:25:38 -0400 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-09-30 18:25:38 -0400 |
commit | c8cb14963511d5d1a3eb46624bcc0d2bcdf3b9bc (patch) | |
tree | 4b44c2814c085b384563bc27b50fdbe8caebe590 /run_exps.py | |
parent | c6adbabd0bf897a1e750fe07bf068e285dd82108 (diff) |
Added more robust error handling inspired by color tests.
Diffstat (limited to 'run_exps.py')
-rwxr-xr-x | run_exps.py | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/run_exps.py b/run_exps.py index 4484952..825ad5b 100755 --- a/run_exps.py +++ b/run_exps.py | |||
@@ -38,13 +38,13 @@ def parse_args(): | |||
38 | def convert_data(data): | 38 | def convert_data(data): |
39 | """Convert a non-python schedule file into the python format""" | 39 | """Convert a non-python schedule file into the python format""" |
40 | regex = re.compile( | 40 | regex = re.compile( |
41 | 41 | r"(?P<PROC>^" | |
42 | r"(?P<PROC>^" | 42 | r"(?P<HEADER>/proc/\w+?/)?" |
43 | r"(?P<HEADER>/proc/\w+?/)?" | 43 | r"(?P<ENTRY>[\w\/]+)" |
44 | r"(?P<ENTRY>[\w\/]+)" | 44 | r"\s*{\s*(?P<CONTENT>.*?)\s*?}$)|" |
45 | r"\s*{\s*(?P<CONTENT>.*?)\s*?}$)|" | 45 | r"(?P<SPIN>^" |
46 | r"(?P<SPIN>^(?P<TYPE>\w+?spin)?\s*?" | 46 | r"(?P<TYPE>\w+?spin)?\s+" |
47 | r"(?P<ARGS>\w[\s\w]*?)?\s*?$)", | 47 | r"(?P<ARGS>[\w\-_\d\. ]+)\s*$)", |
48 | re.S|re.I|re.M) | 48 | re.S|re.I|re.M) |
49 | 49 | ||
50 | procs = [] | 50 | procs = [] |
@@ -63,6 +63,15 @@ def convert_data(data): | |||
63 | 63 | ||
64 | return {'proc' : procs, 'spin' : spins} | 64 | return {'proc' : procs, 'spin' : spins} |
65 | 65 | ||
66 | def fix_paths(schedule, exp_dir): | ||
67 | for (idx, (spin, args)) in enumerate(schedule['spin']): | ||
68 | # Replace relative paths (if present) with absolute ones | ||
69 | for arg in args.split(" "): | ||
70 | abspath = "%s/%s" % (exp_dir, arg) | ||
71 | if os.path.exists(abspath): | ||
72 | args = args.replace(arg, abspath) | ||
73 | |||
74 | schedule['spin'][idx] = (spin, args) | ||
66 | 75 | ||
67 | def get_dirs(sched_file, out_base_dir): | 76 | def get_dirs(sched_file, out_base_dir): |
68 | sched_leaf_dir = re.findall(r".*/([\w_-]+)/.*?$", sched_file)[0] | 77 | sched_leaf_dir = re.findall(r".*/([\w_-]+)/.*?$", sched_file)[0] |
@@ -88,27 +97,27 @@ def load_experiment(sched_file, scheduler, duration, param_file, out_base): | |||
88 | params = {} | 97 | params = {} |
89 | kernel = "" | 98 | kernel = "" |
90 | 99 | ||
91 | if not scheduler or not duration: | 100 | param_file = param_file or \ |
92 | param_file = param_file or \ | 101 | "%s/%s" % (dirname, conf.DEFAULTS['params_file']) |
93 | "%s/%s" % (dirname, conf.DEFAULTS['params_file']) | ||
94 | 102 | ||
95 | if os.path.isfile(param_file): | 103 | if os.path.isfile(param_file): |
96 | params = load_params(param_file) | 104 | params = load_params(param_file) |
97 | scheduler = scheduler or params[conf.PARAMS['sched']] | 105 | scheduler = scheduler or params[conf.PARAMS['sched']] |
98 | duration = duration or params[conf.PARAMS['dur']] | 106 | duration = duration or params[conf.PARAMS['dur']] |
99 | 107 | ||
100 | # Experiments can specify required kernel name | 108 | # Experiments can specify required kernel name |
101 | if conf.PARAMS['kernel'] in params: | 109 | if conf.PARAMS['kernel'] in params: |
102 | kernel = params[conf.PARAMS['kernel']] | 110 | kernel = params[conf.PARAMS['kernel']] |
103 | 111 | ||
104 | duration = duration or conf.DEFAULTS['duration'] | 112 | duration = duration or conf.DEFAULTS['duration'] |
105 | 113 | ||
106 | if not scheduler: | 114 | if not scheduler: |
107 | raise IOError("Parameter scheduler not specified in %s" % (param_file)) | 115 | raise IOError("Parameter scheduler not specified in %s" % (param_file)) |
108 | 116 | ||
109 | # Parse schedule file's intentions | 117 | # Parse schedule file's intentions |
110 | schedule = load_schedule(sched_file) | 118 | schedule = load_schedule(sched_file) |
111 | (work_dir, out_dir) = get_dirs(sched_file, out_base) | 119 | (work_dir, out_dir) = get_dirs(sched_file, out_base) |
120 | fix_paths(schedule, os.path.split(sched_file)[0]) | ||
112 | 121 | ||
113 | run_exp(sched_file, schedule, scheduler, kernel, duration, work_dir, out_dir) | 122 | run_exp(sched_file, schedule, scheduler, kernel, duration, work_dir, out_dir) |
114 | 123 | ||
@@ -170,8 +179,9 @@ def run_exp(name, schedule, scheduler, kernel, duration, work_dir, out_dir): | |||
170 | 179 | ||
171 | exp = Experiment(name, scheduler, work_dir, out_dir, | 180 | exp = Experiment(name, scheduler, work_dir, out_dir, |
172 | proc_entries, executables) | 181 | proc_entries, executables) |
173 | exp.run_exp() | ||
174 | 182 | ||
183 | exp.run_exp() | ||
184 | |||
175 | 185 | ||
176 | def main(): | 186 | def main(): |
177 | opts, args = parse_args() | 187 | opts, args = parse_args() |