Commit 8be8b838 authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

experiments: move runtime classes to separate file

parent 6256bd2e
import modes.experiments as exp
class Run(object):
def __init__(self, experiment, env, outpath):
self.experiment = experiment
self.env = env
self.outpath = outpath
self.output = None
class Runtime(object):
def add_run(self, run):
pass
def start(self):
pass
class LocalSimpleRuntime(Runtime):
def __init__(self):
self.runnable = []
self.complete = []
def add_run(self, run):
self.runnable.append(run)
def start(self):
for run in self.runnable:
run.output = exp.run_exp_local(run.experiment, run.env)
self.complete.append(run)
with open(run.outpath, 'w') as f:
f.write(run.output.dumps())
......@@ -4,40 +4,12 @@ import os
import importlib
import pickle
import modes.experiments as exp
import modes.runtime as runtime
def mkdir_if_not_exists(path):
if not os.path.exists(path):
os.mkdir(path)
class Run(object):
def __init__(self, experiment, env, outpath):
self.experiment = experiment
self.env = env
self.outpath = outpath
self.output = None
class Runtime(object):
def add_run(self, run):
pass
def start(self):
pass
class LocalSimpleRuntime(Runtime):
def __init__(self):
self.runnable = []
self.complete = []
def add_run(self, run):
self.runnable.append(run)
def start(self):
for run in self.runnable:
run.output = exp.run_exp_local(run.experiment, run.env)
self.complete.append(run)
with open(run.outpath, 'w') as f:
f.write(run.output.dumps())
parser = argparse.ArgumentParser()
parser.add_argument('experiments', metavar='EXP', type=str, nargs='+',
......@@ -69,7 +41,7 @@ for path in args.experiments:
mkdir_if_not_exists(args.workdir)
mkdir_if_not_exists(args.outdir)
runtime = LocalSimpleRuntime()
runtime = runtime.LocalSimpleRuntime()
for e in experiments:
workdir_base = '%s/%s' % (args.workdir, e.name)
......
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