forked from M-Labs/artiq
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:
parent
b0f8141018
commit
aa242f7c66
@ -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"])
|
||||
|
@ -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:
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user