From 53cfcf10531256d0e4411a7e0bda431ec27f28e7 Mon Sep 17 00:00:00 2001 From: Jonathan Herman Date: Tue, 30 Oct 2012 16:04:23 -0400 Subject: Process all non-scaling statistics for base experiments. --- parse_exps.py | 53 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 13 deletions(-) (limited to 'parse_exps.py') diff --git a/parse_exps.py b/parse_exps.py index 2d1c370..87d0783 100755 --- a/parse_exps.py +++ b/parse_exps.py @@ -8,6 +8,7 @@ import parse.ft as ft import parse.sched as st import re import shutil as sh +import sys from collections import namedtuple from common import load_params @@ -16,18 +17,20 @@ from parse.point import ExpPoint from parse.tuple_table import ColMap,TupleTable def parse_args(): - # TODO: convert data-dir to proper option + # TODO: convert data-dir to proper option, clean 'dest' options parser = OptionParser("usage: %prog [options] [data_dir]...") parser.add_option('-o', '--out', dest='out', help='file or directory for data output', default='parse-data') - # TODO: this means nothing + # TODO: this means nothing, also remove dests parser.add_option('-c', '--clean', action='store_true', default=False, dest='clean', help='do not output single-point csvs') parser.add_option('-s', '--scale-against', dest='scale_against', metavar='PARAM=VALUE', default="", help='calculate task scaling factors against these configs') + parser.add_option('-i', '--ignore', metavar='[PARAM...]', default="", + help='ignore changing parameter values') parser.add_option('-f', '--force', action='store_true', default=False, dest='force', help='overwrite existing data') parser.add_option('-v', '--verbose', action='store_true', default=False, @@ -38,7 +41,7 @@ def parse_args(): return parser.parse_args() -ExpData = namedtuple('ExpData', ['name', 'params', 'data_files']) +ExpData = namedtuple('ExpData', ['name', 'params', 'data_files', 'is_base']) DataFiles = namedtuple('DataFiles', ['ft','st']) def get_exp_params(data_dir, col_map): @@ -63,7 +66,9 @@ def gen_exp_data(exp_dirs, base_conf, col_map, force): plain_exps = [] scaling_bases = [] - for data_dir in exp_dirs: + sys.stderr.write("Generating data...\n") + + for i, data_dir in enumerate(exp_dirs): if not os.path.isdir(data_dir): raise IOError("Invalid experiment '%s'" % os.path.abspath(data_dir)) @@ -76,18 +81,30 @@ def gen_exp_data(exp_dirs, base_conf, col_map, force): st_output = st.get_st_output(data_dir, tmp_dir, force) ft_output = ft.get_ft_output(data_dir, tmp_dir, force) - # Create experiment named after the data dir - exp_data = ExpData(data_dir, params, DataFiles(ft_output, st_output)) if base_conf and base_conf.viewitems() & params.viewitems(): if not st_output: raise Exception("Scaling base '%s' useless without sched data!" % data_dir) - params.pop(base_conf.keys()[0]) - scaling_bases += [exp_data] + is_base = True + + base_params = copy.deepcopy(params) + base_params.pop(base_conf.keys()[0]) + + base_exp = ExpData(data_dir, base_params, + DataFiles(ft_output, st_output), True) + scaling_bases += [base_exp] else: - plain_exps += [exp_data] + is_base = False + # Create experiment named after the data dir + exp_data = ExpData(data_dir, params, + DataFiles(ft_output, st_output), is_base) + + plain_exps += [exp_data] + + sys.stderr.write('\r {0:.2%}'.format(float(i)/len(exp_dirs))) + sys.stderr.write('\n') return (plain_exps, scaling_bases) def main(): @@ -107,14 +124,20 @@ def main(): raise IOError("Base column '%s' not present in any parameters!" % base_conf.keys()[0]) - base_table = TupleTable(col_map) # For tracking 'base' experiments - result_table = TupleTable(col_map) # For generating csv directories + base_map = copy.deepcopy(col_map) + if opts.ignore: + for param in opts.ignore.split(","): + col_map.try_remove(param) + + base_table = TupleTable(base_map) # For tracking 'base' experiments + result_table = TupleTable(col_map) # For generating output # Used to find matching scaling_base for each experiment for base in scaling_bases: base_table.add_exp(base.params, base) - for exp in plain_exps: + sys.stderr.write("Parsing data...\n") + for i,exp in enumerate(plain_exps): result = ExpPoint(exp.name) if exp.data_files.ft: @@ -123,7 +146,7 @@ def main(): if exp.data_files.st: base = None - if base_conf: + if base_conf and not exp.is_base: # Try to find a scaling base base_params = copy.deepcopy(exp.params) base_params.pop(base_conf.keys()[0]) @@ -137,12 +160,16 @@ def main(): if opts.verbose: print(result) + else: + sys.stderr.write('\r {0:.2%}'.format(float(i)/len(plain_exps))) + sys.stderr.write('\n') if opts.force and os.path.exists(opts.out): sh.rmtree(opts.out) result_table.reduce() + sys.stderr.write("Writing result...\n") if opts.write_map: # Write summarized results into map result_table.write_map(opts.out) -- cgit v1.2.2