forked from M-Labs/artiq
1
0
Fork 0

scheduler: simplify priority policy

Remove overdueness. User must submit calibration experiments with higher priority values for them to take precedence.
This commit is contained in:
Sebastien Bourdeauducq 2015-05-28 18:24:26 +08:00
parent b0f8141018
commit aa242f7c66
3 changed files with 11 additions and 10 deletions

View File

@ -138,8 +138,8 @@ def _show_schedule(schedule):
clear_screen()
if schedule:
l = sorted(schedule.items(),
key=lambda x: (x[1]["due_date"] or 0,
-x[1]["priority"],
key=lambda x: (-x[1]["priority"],
x[1]["due_date"] or 0,
x[0]))
table = PrettyTable(["RID", "Pipeline", " Status ", "Prio",
"Due date", "File", "Experiment", "Arguments"])

View File

@ -17,8 +17,8 @@ class _ScheduleModel(DictSyncModel):
parent, init)
def sort_key(self, k, v):
# order by due date, and then by priority and RID
return (v["due_date"] or 0, -v["priority"], k)
# order by priority, and then by due date and RID
return (-v["priority"], v["due_date"] or 0, k)
def convert(self, k, v, column):
if column == 0:

View File

@ -81,14 +81,16 @@ class Run:
self._notifier[self.rid]["status"] = self._status.name
# The run with the largest priority_key is to be scheduled first
def priority_key(self, now):
def priority_key(self, now=None):
if self.due_date is None:
overdue = 0
due_date_k = 0
else:
overdue = int(now > self.due_date)
due_date_k = -self.due_date
return (overdue, self.priority, due_date_k, -self.rid)
if now is not None and self.due_date is not None:
runnable = int(now > self.due_date)
else:
runnable = 1
return (runnable, self.priority, due_date_k, -self.rid)
@asyncio.coroutine
def close(self):
@ -240,10 +242,9 @@ class RunStage(TaskObject):
next_irun = asyncio_queue_peek(self.inq)
except asyncio.QueueEmpty:
next_irun = None
now = time()
if not stack or (
next_irun is not None and
next_irun.priority_key(now) > stack[-1].priority_key(now)):
next_irun.priority_key() > stack[-1].priority_key()):
stack.append((yield from self.inq.get()))
run = stack.pop()