Commit 254fae55 authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

experiments: remove run_exp_local and use async interface from LocalSimpleRuntime

parent bef83738
...@@ -254,10 +254,4 @@ class ExpOutput(object): ...@@ -254,10 +254,4 @@ class ExpOutput(object):
self.sims[sim.full_name()] = obj self.sims[sim.full_name()] = obj
def dumps(self): def dumps(self):
return json.dumps(self.__dict__) return json.dumps(self.__dict__)
\ No newline at end of file
def run_exp_local(exp, env, verbose=False):
asyncio.run(exp.prepare(env, verbose=verbose))
return asyncio.run(exp.run(env, verbose=verbose))
...@@ -35,16 +35,19 @@ class LocalSimpleRuntime(Runtime): ...@@ -35,16 +35,19 @@ class LocalSimpleRuntime(Runtime):
def add_run(self, run): def add_run(self, run):
self.runnable.append(run) self.runnable.append(run)
async def do_run(self, run):
run.prep_dirs()
await run.experiment.prepare(run.env, verbose=self.verbose)
run.output = await run.experiment.run(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())
def start(self): def start(self):
for run in self.runnable: for run in self.runnable:
run.prep_dirs() asyncio.run(self.do_run(run))
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())
class LocalParallelRuntime(Runtime): class LocalParallelRuntime(Runtime):
......
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