mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-25 03:08:27 +08:00
artiq_run: provide dummy scheduler API
This commit is contained in:
parent
c69c4d5ce9
commit
d01ba8e644
@ -2,6 +2,7 @@
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import time
|
||||
from inspect import isclass
|
||||
from operator import itemgetter
|
||||
from itertools import chain
|
||||
@ -33,6 +34,31 @@ class SimpleParamLogger:
|
||||
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():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Local experiment running tool")
|
||||
@ -111,7 +137,7 @@ def main():
|
||||
print("Failed to parse run arguments")
|
||||
sys.exit(1)
|
||||
|
||||
unit_inst = unit(dbh, **arguments)
|
||||
unit_inst = unit(dbh, scheduler=DummyScheduler(), **arguments)
|
||||
unit_inst.run()
|
||||
if hasattr(unit_inst, "analyze"):
|
||||
unit_inst.analyze()
|
||||
|
Loading…
Reference in New Issue
Block a user