From fc449509b81e1c3544072f8bc7e2a30be23119ee Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 24 May 2015 20:37:47 +0800 Subject: [PATCH] scheduler: pass priority to experiments --- artiq/master/scheduler.py | 3 ++- artiq/master/worker.py | 5 +++-- artiq/master/worker_impl.py | 10 +++++++--- examples/master/repository/flopping_f_simulation.py | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/artiq/master/scheduler.py b/artiq/master/scheduler.py index 30c19d3b4..44b14765d 100644 --- a/artiq/master/scheduler.py +++ b/artiq/master/scheduler.py @@ -98,7 +98,8 @@ class Run: @asyncio.coroutine def prepare(self): - yield from self._prepare(self.rid, self.pipeline_name, self.expid) + yield from self._prepare(self.rid, self.pipeline_name, self.expid, + self.priority) run = _mk_worker_method("run") resume = _mk_worker_method("resume") diff --git a/artiq/master/worker.py b/artiq/master/worker.py index d23a9932a..af7a08990 100644 --- a/artiq/master/worker.py +++ b/artiq/master/worker.py @@ -202,14 +202,15 @@ class Worker: return completed @asyncio.coroutine - def prepare(self, rid, pipeline_name, expid): + def prepare(self, rid, pipeline_name, expid, priority): self.rid = rid yield from self._create_process() yield from self._worker_action( {"action": "prepare", "rid": rid, "pipeline_name": pipeline_name, - "expid": expid}, + "expid": expid, + "priority": priority}, self.prepare_timeout) @asyncio.coroutine diff --git a/artiq/master/worker_impl.py b/artiq/master/worker_impl.py index 722fc3504..18e0e95ec 100644 --- a/artiq/master/worker_impl.py +++ b/artiq/master/worker_impl.py @@ -79,12 +79,13 @@ class Scheduler: pause = staticmethod(make_parent_action("pause", "")) submit = staticmethod(make_parent_action("scheduler_submit", - "pipeline_name expid due_date")) + "pipeline_name expid priority due_date")) cancel = staticmethod(make_parent_action("scheduler_cancel", "rid")) - def __init__(self, pipeline_name, expid): + def __init__(self, pipeline_name, expid, priority): self.pipeline_name = pipeline_name self.expid = expid + self.priority = priority def get_exp(file, exp): @@ -121,9 +122,12 @@ def main(): rid = obj["rid"] pipeline_name = obj["pipeline_name"] expid = obj["expid"] + priority = obj["priority"] exp = get_exp(expid["file"], expid["experiment"]) exp_inst = exp(dbh, - scheduler=Scheduler(pipeline_name, expid), + scheduler=Scheduler(pipeline_name, + expid, + priority), **expid["arguments"]) rdb.build() put_object({"action": "completed"}) diff --git a/examples/master/repository/flopping_f_simulation.py b/examples/master/repository/flopping_f_simulation.py index 9999165e6..9aa2bc9d8 100644 --- a/examples/master/repository/flopping_f_simulation.py +++ b/examples/master/repository/flopping_f_simulation.py @@ -51,7 +51,7 @@ class FloppingF(Experiment, AutoDB): self.brightness.append(brightness) time.sleep(0.1) self.scheduler.submit(self.scheduler.pipeline_name, self.scheduler.expid, - time.time() + 20) + self.scheduler.priority, time.time() + 20) def analyze(self): popt, pcov = curve_fit(model_numpy,