artiq_run: provide dummy scheduler API

This commit is contained in:
Sebastien Bourdeauducq 2015-02-19 12:09:37 -07:00
parent c69c4d5ce9
commit d01ba8e644
1 changed files with 27 additions and 1 deletions

View File

@ -2,6 +2,7 @@
import argparse import argparse
import sys import sys
import time
from inspect import isclass from inspect import isclass
from operator import itemgetter from operator import itemgetter
from itertools import chain from itertools import chain
@ -33,6 +34,31 @@ class SimpleParamLogger:
print("Parameter change: {} -> {}".format(name, value)) print("Parameter change: {} -> {}".format(name, value))
class DummyScheduler:
def __init__(self):
self.next_rid = 0
self.next_trid = 0
def run_queued(self, run_params, timeout):
rid = self.next_rid
self.next_rid += 1
print("Queuing: {}, RID={}".format(run_params, rid))
return rid
def cancel_queued(self, rid):
print("Cancelling RID {}".format(rid))
def run_timed(self, run_params, timeout, next_run):
trid = self.next_trid
self.next_trid += 1
next_run_s = time.strftime("%m/%d %H:%M:%S", time.localtime(next_run))
print("Timing: {} at {}, TRID={}".format(run_params, next_run_s, trid))
return trid
def cancel_timed(self, trid):
print("Cancelling TRID {}".format(trid))
def get_argparser(): def get_argparser():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="Local experiment running tool") description="Local experiment running tool")
@ -111,7 +137,7 @@ def main():
print("Failed to parse run arguments") print("Failed to parse run arguments")
sys.exit(1) sys.exit(1)
unit_inst = unit(dbh, **arguments) unit_inst = unit(dbh, scheduler=DummyScheduler(), **arguments)
unit_inst.run() unit_inst.run()
if hasattr(unit_inst, "analyze"): if hasattr(unit_inst, "analyze"):
unit_inst.analyze() unit_inst.analyze()