aboutsummaryrefslogtreecommitdiffstats
path: root/run_exps.py
diff options
context:
space:
mode:
Diffstat (limited to 'run_exps.py')
-rwxr-xr-xrun_exps.py62
1 files changed, 33 insertions, 29 deletions
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)]