Commit 710f659b authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

experiments: move mkdirs into runtime to avoid special casing for slurm

parent 32fd378d
import tarfile
import io
import pathlib
class NodeConfig(object):
sim = 'qemu'
......
......@@ -37,10 +37,13 @@ class LocalSimpleRuntime(Runtime):
def start(self):
for run in self.runnable:
pathlib.Path(run.env.workdir).mkdir(parents=True, exist_ok=True)
run.output = exp.run_exp_local(run.experiment, run.env,
verbose=self.verbose)
self.complete.append(run)
pathlib.Path(run.outpath).parent.mkdir(parents=True, exist_ok=True)
with open(run.outpath, 'w') as f:
f.write(run.output.dumps())
......@@ -68,9 +71,13 @@ class LocalParallelRuntime(Runtime):
async def do_run(self, run):
''' actually starts a run '''
pathlib.Path(run.env.workdir).mkdir(parents=True, exist_ok=True)
await run.experiment.prepare(run.env, verbose=self.verbose)
print('starting run ', run.name())
run.output = await run.experiment.run(run.env, verbose=self.verbose)
pathlib.Path(run.outpath).parent.mkdir(parents=True, exist_ok=True)
with open(run.outpath, 'w') as f:
f.write(run.output.dumps())
print('finished run ', run.name())
......
......@@ -62,10 +62,6 @@ for path in args.experiments:
with open(path, 'rb') as f:
experiments.append(pickle.load(f))
if args.runtime != 'slurm':
mkdir_if_not_exists(args.workdir)
mkdir_if_not_exists(args.outdir)
if args.runtime == 'parallel':
rt = runtime.LocalParallelRuntime(cores=args.cores, mem=args.mem,
verbose=args.verbose)
......@@ -74,20 +70,15 @@ elif args.runtime == 'slurm':
else:
rt = runtime.LocalSimpleRuntime(verbose=args.verbose)
for e in experiments:
workdir_base = '%s/%s' % (args.workdir, e.name)
if args.runtime != 'slurm':
mkdir_if_not_exists(workdir_base)
for e in experiments:
for run in range(args.firstrun, args.firstrun + args.runs):
outpath = '%s/%s-%d.json' % (args.outdir, e.name, run)
if os.path.exists(outpath):
print('skip %s run %d' % (e.name, run))
continue
workdir = '%s/%d' % (workdir_base, run)
if args.runtime != 'slurm':
mkdir_if_not_exists(workdir)
workdir = '%s/%s/%d' % (args.workdir, e.name, run)
env = exp.ExpEnv(args.repo, workdir)
rt.add_run(runtime.Run(e, run, env, outpath))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment