aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-04-30 11:44:37 -0400
committerJonathan Herman <hermanjl@cs.unc.edu>2013-04-30 11:44:37 -0400
commit94cc65997d237ddeab24d396f06bb93bc0644a9d (patch)
treea402620f54785051ec3b96fa24357cad107299b0
parent648d6381cac8376b5217f915eb49e3aea232df26 (diff)
Cleaned up run_exps.py parameters.
-rw-r--r--README.md6
-rw-r--r--config/config.py18
-rw-r--r--gen/generator.py6
-rwxr-xr-xparse_exps.py4
-rwxr-xr-xrun_exps.py62
5 files changed, 49 insertions, 47 deletions
diff --git a/README.md b/README.md
index b074aa5..1f38978 100644
--- a/README.md
+++ b/README.md
@@ -156,16 +156,14 @@ You can specify your own spin programs to run as well instead of rtspin by putti
156$ echo "colorspin -f color1.csv 10 20" > test.sched 156$ echo "colorspin -f color1.csv 10 20" > test.sched
157``` 157```
158 158
159You can specify parameters for an experiment in a file instead of on the command line using params.py (the `-p` option lets you choose the name of this file if `params.py` is not for you): 159You can specify parameters for an experiment in a file instead of on the command line using params.py:
160 160
161```bash 161```bash
162$ echo "{'scheduler':'GSN-EDF', 'duration':10}" > params.py 162$ echo "{'scheduler':'GSN-EDF', 'duration':10}" > params.py
163$ run_exps.py test.sched 163$ run_exps.py test.sched
164``` 164```
165 165
166You can also run multiple experiments with a single command, provided a directory with a schedule file exists for each. By default, the program will look for sched.py for the schedule file and params.py for the parameter file, but this behavior can be changed using the `-p` and `-c` options. 166You can also run multiple experiments with a single command, provided a directory with a schedule file exists for each. You can include non-relevant parameters which `run_exps.py` does not understand in `params.py`. These parameters will be saved with the data output by `run_exps.py`. This is useful for tracking variations in system parameters versus experimental results. In the following example, multiple experiments are demonstrated and an extra parameter `test-param` is included:
167
168You can include non-relevant parameters which `run_exps.py` does not understand in `params.py`. These parameters will be saved with the data output by `run_exps.py`. This is useful for tracking variations in system parameters versus experimental results. In the following example, multiple experiments are demonstrated and an extra parameter `test-param` is included:
169 167
170```bash 168```bash
171$ mkdir test1 169$ mkdir test1
diff --git a/config/config.py b/config/config.py
index 5e6f9e3..cfdfb05 100644
--- a/config/config.py
+++ b/config/config.py
@@ -14,12 +14,14 @@ BINS = {'rtspin' : get_executable_hint('rtspin', 'liblitmus'),
14 # Optional, as sched_trace is not a publically supported repository 14 # Optional, as sched_trace is not a publically supported repository
15 'st_show' : get_executable_hint('st_show', 'sched_trace', True)} 15 'st_show' : get_executable_hint('st_show', 'sched_trace', True)}
16 16
17'''Names of output files.''' 17'''Names of data files.'''
18FILES = {'ft_data' : 'ft.bin', 18FILES = {'params_file' : 'params.py',
19 'ft_matches' : r'(ft.*\.bin$)|(.*\.ft)', 19 'sched_file' : 'sched.py',
20 'linux_data' : 'trace.dat', 20 'ft_data' : 'ft.bin',
21 'sched_data' : 'st-{}.bin', 21 'ft_matches' : r'(ft.*\.bin$)|(.*\.ft)',
22 'log_data' : 'trace.slog'} 22 'linux_data' : 'trace.dat',
23 'sched_data' : 'st-{}.bin',
24 'log_data' : 'trace.slog'}
23 25
24'''Default parameter names in params.py.''' 26'''Default parameter names in params.py.'''
25PARAMS = {'sched' : 'scheduler', # Scheduler used by run_exps 27PARAMS = {'sched' : 'scheduler', # Scheduler used by run_exps
@@ -35,9 +37,7 @@ PARAMS = {'sched' : 'scheduler', # Scheduler used by run_exps
35 } 37 }
36 38
37'''Default values for program options.''' 39'''Default values for program options.'''
38DEFAULTS = {'params_file' : 'params.py', 40DEFAULTS = {'duration' : 10,
39 'sched_file' : 'sched.py',
40 'duration' : 10,
41 'prog' : 'rtspin', 41 'prog' : 'rtspin',
42 'out-gen' : 'exps', 42 'out-gen' : 'exps',
43 'out-run' : 'run-data', 43 'out-run' : 'run-data',
diff --git a/gen/generator.py b/gen/generator.py
index 6a07616..0999e84 100644
--- a/gen/generator.py
+++ b/gen/generator.py
@@ -6,7 +6,7 @@ import shutil as sh
6 6
7from Cheetah.Template import Template 7from Cheetah.Template import Template
8from common import get_config_option,num_cpus,recordtype 8from common import get_config_option,num_cpus,recordtype
9from config.config import DEFAULTS,PARAMS 9from config.config import FILES,PARAMS
10from gen.dp import DesignPointGenerator 10from gen.dp import DesignPointGenerator
11from parse.col_map import ColMapBuilder 11from parse.col_map import ColMapBuilder
12 12
@@ -121,7 +121,7 @@ class Generator(object):
121 121
122 def _write_schedule(self, params): 122 def _write_schedule(self, params):
123 '''Write schedule file using current template for @params.''' 123 '''Write schedule file using current template for @params.'''
124 sched_file = self.out_dir + "/" + DEFAULTS['sched_file'] 124 sched_file = self.out_dir + "/" + FILES['sched_file']
125 with open(sched_file, 'wa') as f: 125 with open(sched_file, 'wa') as f:
126 f.write(str(Template(self.template, searchList=[params]))) 126 f.write(str(Template(self.template, searchList=[params])))
127 127
@@ -135,7 +135,7 @@ class Generator(object):
135 else: 135 else:
136 tasks = 0 136 tasks = 0
137 137
138 exp_params_file = self.out_dir + "/" + DEFAULTS['params_file'] 138 exp_params_file = self.out_dir + "/" + FILES['params_file']
139 with open(exp_params_file, 'wa') as f: 139 with open(exp_params_file, 'wa') as f:
140 params['scheduler'] = self.scheduler 140 params['scheduler'] = self.scheduler
141 pprint.pprint(params, f) 141 pprint.pprint(params, f)
diff --git a/parse_exps.py b/parse_exps.py
index cc4372a..94c30a4 100755
--- a/parse_exps.py
+++ b/parse_exps.py
@@ -12,7 +12,7 @@ import sys
12import traceback 12import traceback
13 13
14from collections import namedtuple 14from collections import namedtuple
15from config.config import DEFAULTS,PARAMS 15from config.config import FILES,DEFAULTS,PARAMS
16from optparse import OptionParser 16from optparse import OptionParser
17from parse.point import ExpPoint 17from parse.point import ExpPoint
18from parse.tuple_table import TupleTable 18from parse.tuple_table import TupleTable
@@ -85,7 +85,7 @@ def parse_exp(exp_force):
85 85
86 86
87def get_exp_params(data_dir, cm_builder): 87def get_exp_params(data_dir, cm_builder):
88 param_file = "%s/%s" % (data_dir, DEFAULTS['params_file']) 88 param_file = "%s/%s" % (data_dir, FILES['params_file'])
89 if os.path.isfile(param_file): 89 if os.path.isfile(param_file):
90 params = com.load_params(param_file) 90 params = com.load_params(param_file)
91 91
diff --git a/run_exps.py b/run_exps.py
index 1d46b45..1bad2a3 100755
--- a/run_exps.py
+++ b/run_exps.py
@@ -9,9 +9,9 @@ import shutil
9import sys 9import sys
10import run.tracer as trace 10import run.tracer as trace
11 11
12from config.config import PARAMS,DEFAULTS 12from config.config import PARAMS,DEFAULTS,FILES
13from collections import namedtuple 13from collections import namedtuple
14from optparse import OptionParser 14from optparse import OptionParser,OptionGroup
15from parse.enum import Enum 15from parse.enum import Enum
16from run.executable.executable import Executable 16from run.executable.executable import Executable
17from run.experiment import Experiment,ExperimentDone,SystemCorrupted 17from run.experiment import Experiment,ExperimentDone,SystemCorrupted
@@ -61,30 +61,34 @@ def parse_args():
61 61
62 parser.add_option('-s', '--scheduler', dest='scheduler', 62 parser.add_option('-s', '--scheduler', dest='scheduler',
63 help='scheduler for all experiments') 63 help='scheduler for all experiments')
64 parser.add_option('-d', '--duration', dest='duration', type='int',
65 help='duration (seconds) of tasks')
64 parser.add_option('-i', '--ignore-environment', dest='ignore', 66 parser.add_option('-i', '--ignore-environment', dest='ignore',
65 action='store_true', default=False, 67 action='store_true', default=False,
66 help='run experiments even in invalid environments ') 68 help='run experiments even in invalid environments ')
67 parser.add_option('-d', '--duration', dest='duration', type='int', 69 parser.add_option('-f', '--force', action='store_true', default=False,
68 help='duration (seconds) of tasks') 70 dest='force', help='overwrite existing data')
69 parser.add_option('-o', '--out-dir', dest='out_dir', 71 parser.add_option('-o', '--out-dir', dest='out_dir',
70 help='directory for data output', 72 help='directory for data output',
71 default=DEFAULTS['out-run']) 73 default=DEFAULTS['out-run'])
72 parser.add_option('-p', '--params', dest='param_file', 74
73 help='file with experiment parameters') 75 group = OptionGroup(parser, "Communication Options")
74 parser.add_option('-c', '--schedule-file', dest='sched_file', 76 group.add_option('-j', '--jabber', metavar='username@domain',
75 help='name of schedule files within directories', 77 dest='jabber', default=None,
76 default=DEFAULTS['sched_file']) 78 help='send a jabber message when an experiment completes')
77 parser.add_option('-f', '--force', action='store_true', default=False, 79 group.add_option('-e', '--email', metavar='username@server',
78 dest='force', help='overwrite existing data') 80 dest='email', default=None,
79 parser.add_option('-j', '--jabber', metavar='username@domain', 81 help='send an email when all experiments complete')
80 dest='jabber', default=None, 82 parser.add_option_group(group)
81 help='send a jabber message when an experiment completes') 83
82 parser.add_option('-e', '--email', metavar='username@server', 84 group = OptionGroup(parser, "Persistence Options")
83 dest='email', default=None, 85 group.add_option('-r', '--retry', dest='retry', action='store_true',
84 help='send an email when all experiments complete') 86 default=False, help='retry failed experiments')
85 parser.add_option('-r', '--retry', dest='retry', 87 group.add_option('-c', '--crontab', dest='crontab',
86 action='store_true', default=False, 88 action='store_true', default=False,
87 help='retry failed experiments') 89 help='use crontab to resume interrupted script after '
90 'system restarts. implies --retry')
91 parser.add_option_group(group)
88 92
89 return parser.parse_args() 93 return parser.parse_args()
90 94
@@ -220,12 +224,12 @@ def run_script(script_params, exp, exp_dir, out_dir):
220 out.close() 224 out.close()
221 225
222 226
223def make_exp_params(cmd_scheduler, cmd_duration, sched_dir, param_file): 227def make_exp_params(cmd_scheduler, cmd_duration, sched_dir):
224 '''Return ExpParam with configured values of all hardcoded params.''' 228 '''Return ExpParam with configured values of all hardcoded params.'''
225 kernel = copts = "" 229 kernel = copts = ""
226 230
227 # Load parameter file 231 # Load parameter file
228 param_file = param_file or "%s/%s" % (sched_dir, DEFAULTS['params_file']) 232 param_file = "%s/%s" % (sched_dir, FILES['params_file'])
229 if os.path.isfile(param_file): 233 if os.path.isfile(param_file):
230 fparams = com.load_params(param_file) 234 fparams = com.load_params(param_file)
231 else: 235 else:
@@ -303,7 +307,7 @@ def run_experiment(data, start_message, ignore, jabber):
303 if ft_freq: 307 if ft_freq:
304 out_params[PARAMS['cycles']] = ft_freq 308 out_params[PARAMS['cycles']] = ft_freq
305 309
306 out_param_f = "%s/%s" % (data.out_dir, DEFAULTS['params_file']) 310 out_param_f = "%s/%s" % (data.out_dir, FILES['params_file'])
307 with open(out_param_f, 'w') as f: 311 with open(out_param_f, 'w') as f:
308 pprint.pprint(out_params, f) 312 pprint.pprint(out_params, f)
309 313
@@ -320,7 +324,7 @@ def make_paths(exp, opts, out_base_dir):
320 shutil.rmtree(out_dir) 324 shutil.rmtree(out_dir)
321 325
322 if os.path.isdir(path): 326 if os.path.isdir(path):
323 sched_file = "%s/%s" % (path, opts.sched_file) 327 sched_file = "%s/%s" % (path, FILES['sched_file'])
324 else: 328 else:
325 sched_file = path 329 sched_file = path
326 330
@@ -348,10 +352,10 @@ def get_exps(opts, args, out_base_dir):
348 '''Return list of ExpDatas''' 352 '''Return list of ExpDatas'''
349 353
350 if not args: 354 if not args:
351 if os.path.exists(opts.sched_file): 355 if os.path.exists(FILES['sched_file']):
352 # Default to sched_file in current directory 356 # Default to sched_file in current directory
353 sys.stderr.write("Reading schedule from %s.\n" % opts.sched_file) 357 sys.stderr.write("Reading schedule from %s.\n" % FILES['sched_file'])
354 args = [opts.sched_file] 358 args = [FILES['sched_file']]
355 elif os.path.exists(DEFAULTS['out-gen']): 359 elif os.path.exists(DEFAULTS['out-gen']):
356 # Then try experiments created by gen_exps 360 # Then try experiments created by gen_exps
357 sys.stderr.write("Reading schedules from %s/*.\n" % DEFAULTS['out-gen']) 361 sys.stderr.write("Reading schedules from %s/*.\n" % DEFAULTS['out-gen'])
@@ -370,8 +374,8 @@ def get_exps(opts, args, out_base_dir):
370 name = path[len(common):] 374 name = path[len(common):]
371 375
372 sched_dir = os.path.split(sched_file)[0] 376 sched_dir = os.path.split(sched_file)[0]
373 exp_params = make_exp_params(opts.scheduler, opts.duration, 377
374 sched_dir, opts.param_file) 378 exp_params = make_exp_params(opts.scheduler, opts.duration, sched_dir)
375 379
376 exps += [ExpData(name, exp_params, sched_file, out_dir, 380 exps += [ExpData(name, exp_params, sched_file, out_dir,
377 0, ExpState.None)] 381 0, ExpState.None)]