From 0dd5692c326a96382b03b10d5aa0529f60564f06 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 19 Feb 2015 20:05:12 -0700 Subject: [PATCH] master,run: pass run_params to experiment --- artiq/frontend/artiq_run.py | 11 ++++++++++- artiq/master/worker_impl.py | 11 +++++++---- examples/flopping_f_simulation.py | 10 +--------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/artiq/frontend/artiq_run.py b/artiq/frontend/artiq_run.py index 383f8914f..2aad26c7b 100755 --- a/artiq/frontend/artiq_run.py +++ b/artiq/frontend/artiq_run.py @@ -137,7 +137,16 @@ def main(): print("Failed to parse run arguments") 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() if hasattr(unit_inst, "analyze"): unit_inst.analyze() diff --git a/artiq/master/worker_impl.py b/artiq/master/worker_impl.py index 0a7627afc..4965d9ede 100644 --- a/artiq/master/worker_impl.py +++ b/artiq/master/worker_impl.py @@ -81,8 +81,8 @@ def get_unit(file, unit): return getattr(module, unit) -def run(obj): - unit = get_unit(obj["file"], obj["unit"]) +def run(run_params): + unit = get_unit(run_params["file"], run_params["unit"]) realtime_results = unit.realtime_results() init_rt_results(realtime_results) @@ -100,7 +100,10 @@ def run(obj): dbh = DBHub(ParentDDB, ParentPDB, rdb) 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() if hasattr(unit_inst, "analyze"): unit_inst.analyze() @@ -114,7 +117,7 @@ def run(obj): finally: dbh.close() - filename = obj["file"] + ".h5" + filename = run_params["file"] + ".h5" f = h5py.File(filename, "w") try: rdb.write_hdf5(f) diff --git a/examples/flopping_f_simulation.py b/examples/flopping_f_simulation.py index cd7564526..c128aeaa3 100644 --- a/examples/flopping_f_simulation.py +++ b/examples/flopping_f_simulation.py @@ -52,15 +52,7 @@ class FloppingF(AutoDB): self.frequency.append(frequency) self.brightness.append(brightness) time.sleep(0.1) - - 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) + self.scheduler.run_timed(self.run_params, time.time() + 20) def analyze(self): popt, pcov = curve_fit(model_numpy,