forked from M-Labs/artiq
1
0
Fork 0

expid: experiment -> class_name

This commit is contained in:
Sebastien Bourdeauducq 2015-07-15 11:08:12 +02:00
parent 255aba9247
commit 84de2fb28b
7 changed files with 20 additions and 20 deletions

View File

@ -43,8 +43,8 @@ def get_argparser():
parser_add.add_argument("-f", "--flush", default=False, action="store_true", parser_add.add_argument("-f", "--flush", default=False, action="store_true",
help="flush the pipeline before preparing " help="flush the pipeline before preparing "
"the experiment") "the experiment")
parser_add.add_argument("-e", "--experiment", default=None, parser_add.add_argument("-c", "--class-name", default=None,
help="experiment to run") help="name of the class to run")
parser_add.add_argument("file", parser_add.add_argument("file",
help="file containing the experiment to run") help="file containing the experiment to run")
parser_add.add_argument("arguments", nargs="*", parser_add.add_argument("arguments", nargs="*",
@ -102,7 +102,7 @@ def _action_submit(remote, args):
expid = { expid = {
"file": args.file, "file": args.file,
"experiment": args.experiment, "class_name": args.class_name,
"arguments": arguments, "arguments": arguments,
} }
if args.timed is None: if args.timed is None:
@ -142,7 +142,7 @@ def _show_schedule(schedule):
x[1]["due_date"] or 0, x[1]["due_date"] or 0,
x[0])) x[0]))
table = PrettyTable(["RID", "Pipeline", " Status ", "Prio", table = PrettyTable(["RID", "Pipeline", " Status ", "Prio",
"Due date", "File", "Experiment", "Arguments"]) "Due date", "File", "Class name", "Arguments"])
for rid, v in l: for rid, v in l:
row = [rid, v["pipeline"], v["status"], v["priority"]] row = [rid, v["pipeline"], v["status"], v["priority"]]
if v["due_date"] is None: if v["due_date"] is None:
@ -151,10 +151,10 @@ def _show_schedule(schedule):
row.append(time.strftime("%m/%d %H:%M:%S", row.append(time.strftime("%m/%d %H:%M:%S",
time.localtime(v["due_date"]))) time.localtime(v["due_date"])))
row.append(v["expid"]["file"]) row.append(v["expid"]["file"])
if v["expid"]["experiment"] is None: if v["expid"]["class_name"] is None:
row.append("") row.append("")
else: else:
row.append(v["expid"]["experiment"]) row.append(v["expid"]["class_name"])
row.append(format_arguments(v["expid"]["arguments"])) row.append(format_arguments(v["expid"]["arguments"]))
table.add_row(row) table.add_row(row)
print(table) print(table)

View File

@ -85,11 +85,11 @@ class ExplorerDock(dockarea.Dock):
return self.explist_model return self.explist_model
@asyncio.coroutine @asyncio.coroutine
def submit(self, pipeline_name, file, experiment, arguments, def submit(self, pipeline_name, file, class_name, arguments,
priority, due_date, flush): priority, due_date, flush):
expid = { expid = {
"file": file, "file": file,
"experiment": experiment, "class_name": class_name,
"arguments": arguments, "arguments": arguments,
} }
rid = yield from self.schedule_ctl.submit(pipeline_name, expid, rid = yield from self.schedule_ctl.submit(pipeline_name, expid,
@ -107,6 +107,6 @@ class ExplorerDock(dockarea.Dock):
else: else:
due_date = None due_date = None
asyncio.async(self.submit(self.pipeline.text(), asyncio.async(self.submit(self.pipeline.text(),
expinfo["file"], expinfo["experiment"], expinfo["file"], expinfo["class_name"],
dict(), self.priority.value(), due_date, dict(), self.priority.value(), due_date,
self.flush.isChecked())) self.flush.isChecked()))

View File

@ -13,7 +13,7 @@ class _ScheduleModel(DictSyncModel):
def __init__(self, parent, init): def __init__(self, parent, init):
DictSyncModel.__init__(self, DictSyncModel.__init__(self,
["RID", "Pipeline", "Status", "Prio", "Due date", ["RID", "Pipeline", "Status", "Prio", "Due date",
"File", "Experiment", "Arguments"], "File", "Class name", "Arguments"],
parent, init) parent, init)
def sort_key(self, k, v): def sort_key(self, k, v):
@ -38,10 +38,10 @@ class _ScheduleModel(DictSyncModel):
elif column == 5: elif column == 5:
return v["expid"]["file"] return v["expid"]["file"]
elif column == 6: elif column == 6:
if v["expid"]["experiment"] is None: if v["expid"]["class_name"] is None:
return "" return ""
else: else:
return v["expid"]["experiment"] return v["expid"]["class_name"]
elif column == 7: elif column == 7:
return format_arguments(v["expid"]["arguments"]) return format_arguments(v["expid"]["arguments"])
else: else:

View File

@ -86,9 +86,9 @@ class Scheduler:
self.priority = priority self.priority = priority
def get_exp(file, exp): def get_exp(file, class_name):
module = file_import(file) module = file_import(file)
if exp is None: if class_name is None:
exps = [v for k, v in module.__dict__.items() exps = [v for k, v in module.__dict__.items()
if is_experiment(v)] if is_experiment(v)]
if len(exps) != 1: if len(exps) != 1:
@ -96,7 +96,7 @@ def get_exp(file, exp):
.format(len(exps))) .format(len(exps)))
return exps[0] return exps[0]
else: else:
return getattr(module, exp) return getattr(module, class_name)
register_experiment = make_parent_action("register_experiment", register_experiment = make_parent_action("register_experiment",
@ -154,7 +154,7 @@ def main():
start_time = time.localtime() start_time = time.localtime()
rid = obj["rid"] rid = obj["rid"]
expid = obj["expid"] expid = obj["expid"]
exp = get_exp(expid["file"], expid["experiment"]) exp = get_exp(expid["file"], expid["class_name"])
dmgr.virtual_devices["scheduler"].set_run_info( dmgr.virtual_devices["scheduler"].set_run_info(
obj["pipeline_name"], expid, obj["priority"]) obj["pipeline_name"], expid, obj["priority"])
exp_inst = exp(dmgr, ParentPDB, rdb, exp_inst = exp(dmgr, ParentPDB, rdb,

View File

@ -40,7 +40,7 @@ class ExperimentCase(unittest.TestCase):
def execute(self, cls, **kwargs): def execute(self, cls, **kwargs):
expid = { expid = {
"file": sys.modules[cls.__module__].__file__, "file": sys.modules[cls.__module__].__file__,
"experiment": cls.__name__, "class_name": cls.__name__,
"arguments": kwargs "arguments": kwargs
} }
self.dmgr.virtual_devices["scheduler"].expid = expid self.dmgr.virtual_devices["scheduler"].expid = expid

View File

@ -28,7 +28,7 @@ class BackgroundExperiment(EnvExperiment):
def _get_expid(name): def _get_expid(name):
return { return {
"file": sys.modules[__name__].__file__, "file": sys.modules[__name__].__file__,
"experiment": name, "class_name": name,
"arguments": dict() "arguments": dict()
} }

View File

@ -46,10 +46,10 @@ def _call_worker(worker, expid):
yield from worker.close() yield from worker.close()
def _run_experiment(experiment): def _run_experiment(class_name):
expid = { expid = {
"file": sys.modules[__name__].__file__, "file": sys.modules[__name__].__file__,
"experiment": experiment, "class_name": class_name,
"arguments": dict() "arguments": dict()
} }
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()