Skip to content

Commit

Permalink
scheduler: Replace notify by monitor.record
Browse files Browse the repository at this point in the history
  • Loading branch information
Deepskyhunter committed Jul 29, 2022
1 parent ada6d27 commit 0efa3db
Showing 1 changed file with 7 additions and 31 deletions.
38 changes: 7 additions & 31 deletions artiq/test/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def __init__(self):
self.exp_flow = {}
self.flags = {"arrive": {}, "leave": {}}

def record(self):
def record(self, mod):
process_mod(self.experiments, mod)
for key, value in self.experiments.items():
if key not in self.last_status.keys():
self.last_status[key] = ""
Expand Down Expand Up @@ -132,12 +133,7 @@ def test_steps(self):
scheduler = Scheduler(_RIDCounter(0), dict(), None, None)
expid = _get_expid("EmptyExperiment")
monitor = SchedulerMonitor()

def notify(mod):
process_mod(monitor.experiments, mod)
monitor.record()
scheduler.notifier.publish = notify

scheduler.notifier.publish = monitor.record
scheduler.start()

# Verify that a timed experiment far in the future does not
Expand Down Expand Up @@ -175,13 +171,7 @@ def test_pending_priority(self):
early = time() + 1

monitor = SchedulerMonitor()

def notify(mod):
process_mod(monitor.experiments, mod)
monitor.record()

scheduler.notifier.publish = notify

scheduler.notifier.publish = monitor.record
scheduler.start()

scheduler.submit("main", expid_bg, low_priority)
Expand Down Expand Up @@ -224,11 +214,7 @@ def check_termination(mod):
expid = _get_expid("EmptyExperiment")

monitor = SchedulerMonitor()
def notify(mod):
process_mod(monitor.experiments, mod)
monitor.record()
scheduler.notifier.publish = notify

scheduler.notifier.publish = monitor.record
scheduler.start()
# check_pause is True when rid with higher priority is prepare_done
scheduler.submit("main", expid_bg, -99, None, False)
Expand Down Expand Up @@ -264,12 +250,7 @@ def test_close_with_active_runs(self):
monitor = SchedulerMonitor()
expid = _get_expid("EmptyExperiment")

def notify(mod):
process_mod(monitor.experiments, mod)
monitor.record()

scheduler.notifier.publish = notify

scheduler.notifier.publish = monitor.record
scheduler.start()
scheduler.submit("main", expid_bg, -99, None, False)
loop.run_until_complete(monitor.wait_until(0, "arrive", "running"))
Expand All @@ -291,12 +272,7 @@ def test_flush(self):
expid_bg["log_level"] = logging.CRITICAL
monitor = SchedulerMonitor()

def notify(mod):
process_mod(monitor.experiments, mod)
monitor.record()

scheduler.notifier.publish = notify

scheduler.notifier.publish = monitor.record
scheduler.start()
# Flush with same priority
scheduler.submit("main", expid, 0, None, False)
Expand Down

0 comments on commit 0efa3db

Please sign in to comment.