forked from M-Labs/artiq
expid: experiment -> class_name
This commit is contained in:
parent
255aba9247
commit
84de2fb28b
@ -43,8 +43,8 @@ def get_argparser():
|
||||
parser_add.add_argument("-f", "--flush", default=False, action="store_true",
|
||||
help="flush the pipeline before preparing "
|
||||
"the experiment")
|
||||
parser_add.add_argument("-e", "--experiment", default=None,
|
||||
help="experiment to run")
|
||||
parser_add.add_argument("-c", "--class-name", default=None,
|
||||
help="name of the class to run")
|
||||
parser_add.add_argument("file",
|
||||
help="file containing the experiment to run")
|
||||
parser_add.add_argument("arguments", nargs="*",
|
||||
@ -102,7 +102,7 @@ def _action_submit(remote, args):
|
||||
|
||||
expid = {
|
||||
"file": args.file,
|
||||
"experiment": args.experiment,
|
||||
"class_name": args.class_name,
|
||||
"arguments": arguments,
|
||||
}
|
||||
if args.timed is None:
|
||||
@ -142,7 +142,7 @@ def _show_schedule(schedule):
|
||||
x[1]["due_date"] or 0,
|
||||
x[0]))
|
||||
table = PrettyTable(["RID", "Pipeline", " Status ", "Prio",
|
||||
"Due date", "File", "Experiment", "Arguments"])
|
||||
"Due date", "File", "Class name", "Arguments"])
|
||||
for rid, v in l:
|
||||
row = [rid, v["pipeline"], v["status"], v["priority"]]
|
||||
if v["due_date"] is None:
|
||||
@ -151,10 +151,10 @@ def _show_schedule(schedule):
|
||||
row.append(time.strftime("%m/%d %H:%M:%S",
|
||||
time.localtime(v["due_date"])))
|
||||
row.append(v["expid"]["file"])
|
||||
if v["expid"]["experiment"] is None:
|
||||
if v["expid"]["class_name"] is None:
|
||||
row.append("")
|
||||
else:
|
||||
row.append(v["expid"]["experiment"])
|
||||
row.append(v["expid"]["class_name"])
|
||||
row.append(format_arguments(v["expid"]["arguments"]))
|
||||
table.add_row(row)
|
||||
print(table)
|
||||
|
@ -85,11 +85,11 @@ class ExplorerDock(dockarea.Dock):
|
||||
return self.explist_model
|
||||
|
||||
@asyncio.coroutine
|
||||
def submit(self, pipeline_name, file, experiment, arguments,
|
||||
def submit(self, pipeline_name, file, class_name, arguments,
|
||||
priority, due_date, flush):
|
||||
expid = {
|
||||
"file": file,
|
||||
"experiment": experiment,
|
||||
"class_name": class_name,
|
||||
"arguments": arguments,
|
||||
}
|
||||
rid = yield from self.schedule_ctl.submit(pipeline_name, expid,
|
||||
@ -107,6 +107,6 @@ class ExplorerDock(dockarea.Dock):
|
||||
else:
|
||||
due_date = None
|
||||
asyncio.async(self.submit(self.pipeline.text(),
|
||||
expinfo["file"], expinfo["experiment"],
|
||||
expinfo["file"], expinfo["class_name"],
|
||||
dict(), self.priority.value(), due_date,
|
||||
self.flush.isChecked()))
|
||||
|
@ -13,7 +13,7 @@ class _ScheduleModel(DictSyncModel):
|
||||
def __init__(self, parent, init):
|
||||
DictSyncModel.__init__(self,
|
||||
["RID", "Pipeline", "Status", "Prio", "Due date",
|
||||
"File", "Experiment", "Arguments"],
|
||||
"File", "Class name", "Arguments"],
|
||||
parent, init)
|
||||
|
||||
def sort_key(self, k, v):
|
||||
@ -38,10 +38,10 @@ class _ScheduleModel(DictSyncModel):
|
||||
elif column == 5:
|
||||
return v["expid"]["file"]
|
||||
elif column == 6:
|
||||
if v["expid"]["experiment"] is None:
|
||||
if v["expid"]["class_name"] is None:
|
||||
return ""
|
||||
else:
|
||||
return v["expid"]["experiment"]
|
||||
return v["expid"]["class_name"]
|
||||
elif column == 7:
|
||||
return format_arguments(v["expid"]["arguments"])
|
||||
else:
|
||||
|
@ -86,9 +86,9 @@ class Scheduler:
|
||||
self.priority = priority
|
||||
|
||||
|
||||
def get_exp(file, exp):
|
||||
def get_exp(file, class_name):
|
||||
module = file_import(file)
|
||||
if exp is None:
|
||||
if class_name is None:
|
||||
exps = [v for k, v in module.__dict__.items()
|
||||
if is_experiment(v)]
|
||||
if len(exps) != 1:
|
||||
@ -96,7 +96,7 @@ def get_exp(file, exp):
|
||||
.format(len(exps)))
|
||||
return exps[0]
|
||||
else:
|
||||
return getattr(module, exp)
|
||||
return getattr(module, class_name)
|
||||
|
||||
|
||||
register_experiment = make_parent_action("register_experiment",
|
||||
@ -154,7 +154,7 @@ def main():
|
||||
start_time = time.localtime()
|
||||
rid = obj["rid"]
|
||||
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(
|
||||
obj["pipeline_name"], expid, obj["priority"])
|
||||
exp_inst = exp(dmgr, ParentPDB, rdb,
|
||||
|
@ -40,7 +40,7 @@ class ExperimentCase(unittest.TestCase):
|
||||
def execute(self, cls, **kwargs):
|
||||
expid = {
|
||||
"file": sys.modules[cls.__module__].__file__,
|
||||
"experiment": cls.__name__,
|
||||
"class_name": cls.__name__,
|
||||
"arguments": kwargs
|
||||
}
|
||||
self.dmgr.virtual_devices["scheduler"].expid = expid
|
||||
|
@ -28,7 +28,7 @@ class BackgroundExperiment(EnvExperiment):
|
||||
def _get_expid(name):
|
||||
return {
|
||||
"file": sys.modules[__name__].__file__,
|
||||
"experiment": name,
|
||||
"class_name": name,
|
||||
"arguments": dict()
|
||||
}
|
||||
|
||||
|
@ -46,10 +46,10 @@ def _call_worker(worker, expid):
|
||||
yield from worker.close()
|
||||
|
||||
|
||||
def _run_experiment(experiment):
|
||||
def _run_experiment(class_name):
|
||||
expid = {
|
||||
"file": sys.modules[__name__].__file__,
|
||||
"experiment": experiment,
|
||||
"class_name": class_name,
|
||||
"arguments": dict()
|
||||
}
|
||||
loop = asyncio.get_event_loop()
|
||||
|
Loading…
Reference in New Issue
Block a user