aboutsummaryrefslogtreecommitdiffstats
path: root/parse_exps.py
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-03-18 13:15:42 -0400
committerJonathan Herman <hermanjl@cs.unc.edu>2013-03-18 13:15:42 -0400
commit16dfc8df20c6befeed423217a2e0f5ae59b5a04d (patch)
tree722ff18b111f6ab2fc11fffa46e78889bd2d5708 /parse_exps.py
parent652a57b5a53e41e585c7e0d10601c807ba08c36f (diff)
Use smarter defaults which can handle data from Bjorns scripts.
Diffstat (limited to 'parse_exps.py')
-rwxr-xr-xparse_exps.py35
1 files changed, 21 insertions, 14 deletions
diff --git a/parse_exps.py b/parse_exps.py
index 7dfc9cd..8fcf5c3 100755
--- a/parse_exps.py
+++ b/parse_exps.py
@@ -22,8 +22,6 @@ def parse_args():
22 # TODO: convert data-dir to proper option, clean 'dest' options 22 # TODO: convert data-dir to proper option, clean 'dest' options
23 parser = OptionParser("usage: %prog [options] [data_dir]...") 23 parser = OptionParser("usage: %prog [options] [data_dir]...")
24 24
25 print("default to no params.py")
26
27 parser.add_option('-o', '--out', dest='out', 25 parser.add_option('-o', '--out', dest='out',
28 help='file or directory for data output', default='parse-data') 26 help='file or directory for data output', default='parse-data')
29 parser.add_option('-c', '--clean', action='store_true', default=False, 27 parser.add_option('-c', '--clean', action='store_true', default=False,
@@ -44,15 +42,15 @@ ExpData = namedtuple('ExpData', ['path', 'params', 'work_dir'])
44 42
45def get_exp_params(data_dir, cm_builder): 43def get_exp_params(data_dir, cm_builder):
46 param_file = "%s/%s" % (data_dir, conf.DEFAULTS['params_file']) 44 param_file = "%s/%s" % (data_dir, conf.DEFAULTS['params_file'])
47 if not os.path.isfile: 45 if os.path.isfile(param_file):
48 raise Exception("No param file '%s' exists!" % param_file) 46 params = load_params(param_file)
49
50 params = load_params(param_file)
51 47
52 # Store parameters in cm_builder, which will track which parameters change 48 # Store parameters in cm_builder, which will track which parameters change
53 # across experiments 49 # across experiments
54 for key, value in params.iteritems(): 50 for key, value in params.iteritems():
55 cm_builder.try_add(key, value) 51 cm_builder.try_add(key, value)
52 else:
53 params = {}
56 54
57 # Cycles must be present for feather-trace measurement parsing 55 # Cycles must be present for feather-trace measurement parsing
58 if conf.PARAMS['cycles'] not in params: 56 if conf.PARAMS['cycles'] not in params:
@@ -164,16 +162,25 @@ def main():
164 if opts.force and os.path.exists(opts.out): 162 if opts.force and os.path.exists(opts.out):
165 sh.rmtree(opts.out) 163 sh.rmtree(opts.out)
166 164
167 result_table = result_table.reduce() 165 reduced_table = result_table.reduce()
168 166
169 sys.stderr.write("Writing result...\n") 167 sys.stderr.write("Writing result...\n")
170 if opts.write_map: 168 if opts.write_map:
171 # Write summarized results into map 169 # Write summarized results into map
172 result_table.write_map(opts.out) 170 reduced_table.write_map(opts.out)
173 else: 171 else:
174 # Write out csv directories for all variable params 172 # Write out csv directories for all variable params
175 dir_map = result_table.to_dir_map() 173 dir_map = reduced_table.to_dir_map()
176 dir_map.write(opts.out) 174
175 # No csvs to write, assume user meant to print out data
176 if dir_map.is_empty():
177 sys.stderr.write("Too little data to make csv files.\n")
178 if not opts.verbose:
179 for key, exp in result_table:
180 for e in exp:
181 print(e)
182 else:
183 dir_map.write(opts.out)
177 184
178if __name__ == '__main__': 185if __name__ == '__main__':
179 main() 186 main()