master,run: pass run_params to experiment

This commit is contained in:
Sebastien Bourdeauducq 2015-02-19 20:05:12 -07:00
parent 4d21b78314
commit 0dd5692c32
3 changed files with 18 additions and 14 deletions

View File

@ -137,7 +137,16 @@ def main():
print("Failed to parse run arguments") print("Failed to parse run arguments")
sys.exit(1) sys.exit(1)
unit_inst = unit(dbh, scheduler=DummyScheduler(), **arguments) run_params = {
"file": args.file,
"unit": args.unit,
"timeout": None,
"arguments": arguments
}
unit_inst = unit(dbh,
scheduler=DummyScheduler(),
run_params=run_params,
**run_params["arguments"])
unit_inst.run() unit_inst.run()
if hasattr(unit_inst, "analyze"): if hasattr(unit_inst, "analyze"):
unit_inst.analyze() unit_inst.analyze()

View File

@ -81,8 +81,8 @@ def get_unit(file, unit):
return getattr(module, unit) return getattr(module, unit)
def run(obj): def run(run_params):
unit = get_unit(obj["file"], obj["unit"]) unit = get_unit(run_params["file"], run_params["unit"])
realtime_results = unit.realtime_results() realtime_results = unit.realtime_results()
init_rt_results(realtime_results) init_rt_results(realtime_results)
@ -100,7 +100,10 @@ def run(obj):
dbh = DBHub(ParentDDB, ParentPDB, rdb) dbh = DBHub(ParentDDB, ParentPDB, rdb)
try: try:
try: try:
unit_inst = unit(dbh, scheduler=Scheduler, **obj["arguments"]) unit_inst = unit(dbh,
scheduler=Scheduler,
run_params=run_params,
**run_params["arguments"])
unit_inst.run() unit_inst.run()
if hasattr(unit_inst, "analyze"): if hasattr(unit_inst, "analyze"):
unit_inst.analyze() unit_inst.analyze()
@ -114,7 +117,7 @@ def run(obj):
finally: finally:
dbh.close() dbh.close()
filename = obj["file"] + ".h5" filename = run_params["file"] + ".h5"
f = h5py.File(filename, "w") f = h5py.File(filename, "w")
try: try:
rdb.write_hdf5(f) rdb.write_hdf5(f)

View File

@ -52,15 +52,7 @@ class FloppingF(AutoDB):
self.frequency.append(frequency) self.frequency.append(frequency)
self.brightness.append(brightness) self.brightness.append(brightness)
time.sleep(0.1) time.sleep(0.1)
self.scheduler.run_timed(self.run_params, time.time() + 20)
run_params = {
"file": "flopping_f_simulation.py",
"unit": None,
"timeout": None,
"arguments": dict(),
"rtr_group": "flopping_f_simulation.py"
}
self.scheduler.run_timed(run_params, time.time() + 20)
def analyze(self): def analyze(self):
popt, pcov = curve_fit(model_numpy, popt, pcov = curve_fit(model_numpy,