forked from M-Labs/artiq
1
0
Fork 0

gui: experiment submission

This commit is contained in:
Sebastien Bourdeauducq 2015-05-24 20:24:07 +08:00
parent a21373841c
commit e611e17eeb
2 changed files with 89 additions and 17 deletions

View File

@ -10,6 +10,7 @@ from quamash import QEventLoop, QtGui
from pyqtgraph import dockarea
from artiq.protocols.file_db import FlatFileDB
from artiq.protocols.pc_rpc import AsyncioClient
from artiq.gui.explorer import ExplorerDock
from artiq.gui.parameters import ParametersDock
from artiq.gui.log import LogDock
@ -43,6 +44,11 @@ def main():
asyncio.set_event_loop(loop)
atexit.register(lambda: loop.close())
schedule_ctl = AsyncioClient()
loop.run_until_complete(schedule_ctl.connect_rpc(
args.server, args.port_control, "master_schedule"))
atexit.register(lambda: schedule_ctl.close_rpc())
win = QtGui.QMainWindow()
area = dockarea.DockArea()
win.setCentralWidget(area)
@ -52,8 +58,11 @@ def main():
win.resize(1400, 800)
win.setWindowTitle("ARTIQ")
d_explorer = ExplorerDock()
d_explorer = ExplorerDock(status_bar, schedule_ctl)
area.addDock(d_explorer, "top")
loop.run_until_complete(d_explorer.sub_connect(
args.server, args.port_notify))
atexit.register(lambda: loop.run_until_complete(d_explorer.sub_close()))
d_params = ParametersDock()
area.addDock(d_params, "right", d_explorer)

View File

@ -1,41 +1,104 @@
import asyncio
from quamash import QtGui, QtCore
from pyqtgraph import dockarea
from pyqtgraph import LayoutWidget
from artiq.protocols.sync_struct import Subscriber
from artiq.gui.tools import DictSyncModel
class _ExplistModel(DictSyncModel):
def __init__(self, parent, init):
DictSyncModel.__init__(self,
["Experiment"],
parent, init)
def sort_key(self, k, v):
return k
def convert(self, k, v, column):
return k
class ExplorerDock(dockarea.Dock):
def __init__(self):
def __init__(self, status_bar, schedule_ctl):
dockarea.Dock.__init__(self, "Explorer", size=(1100, 400))
self.status_bar = status_bar
self.schedule_ctl = schedule_ctl
splitter = QtGui.QSplitter(QtCore.Qt.Horizontal)
self.addWidget(splitter)
grid = LayoutWidget()
splitter.addWidget(grid)
el = QtGui.QListView()
grid.addWidget(el, 0, 0, colspan=4)
self.el = QtGui.QListView()
grid.addWidget(self.el, 0, 0, colspan=4)
datetime = QtGui.QDateTimeEdit()
datetime.setDisplayFormat("MMM d yyyy hh:mm:ss")
datetime.setCalendarPopup(True)
datetime.setDate(QtCore.QDate.currentDate())
datetime_en = QtGui.QCheckBox("Set due date:")
grid.addWidget(datetime_en, 1, 0)
grid.addWidget(datetime, 1, 1, colspan=3)
self.datetime = QtGui.QDateTimeEdit()
self.datetime.setDisplayFormat("MMM d yyyy hh:mm:ss")
self.datetime.setCalendarPopup(True)
self.datetime.setDate(QtCore.QDate.currentDate())
self.datetime_en = QtGui.QCheckBox("Set due date:")
grid.addWidget(self.datetime_en, 1, 0)
grid.addWidget(self.datetime, 1, 1, colspan=3)
pipeline = QtGui.QLineEdit()
pipeline.insert("main")
self.pipeline = QtGui.QLineEdit()
self.pipeline.insert("main")
grid.addLabel("Pipeline:", 2, 0)
grid.addWidget(pipeline, 2, 1)
grid.addWidget(self.pipeline, 2, 1)
priority = QtGui.QSpinBox()
priority.setRange(-99, 99)
self.priority = QtGui.QSpinBox()
self.priority.setRange(-99, 99)
grid.addLabel("Priority:", 2, 2)
grid.addWidget(priority, 2, 3)
grid.addWidget(self.priority, 2, 3)
submit = QtGui.QPushButton("Submit")
grid.addWidget(submit, 3, 0, colspan=4)
submit.clicked.connect(self.submit_clicked)
placeholder = QtGui.QWidget()
splitter.addWidget(placeholder)
@asyncio.coroutine
def sub_connect(self, host, port):
self.explist_subscriber = Subscriber("explist",
self.init_explist_model)
yield from self.explist_subscriber.connect(host, port)
@asyncio.coroutine
def sub_close(self):
yield from self.explist_subscriber.close()
def init_explist_model(self, init):
self.explist_model = _ExplistModel(self.el, init)
self.el.setModel(self.explist_model)
return self.explist_model
@asyncio.coroutine
def submit(self, pipeline_name, file, experiment, arguments,
priority, due_date):
expid = {
"file": file,
"experiment": experiment,
"arguments": arguments,
}
rid = yield from self.schedule_ctl.submit(pipeline_name, expid,
priority, due_date)
self.status_bar.showMessage("Submitted RID {}".format(rid))
def submit_clicked(self):
idx = self.el.selectedIndexes()
if idx:
row = idx[0].row()
key = self.explist_model.row_to_key[row]
expinfo = self.explist_model.data[key]
if self.datetime_en.isChecked():
due_date = self.datetime.dateTime().toMSecsSinceEpoch()/1000
else:
due_date = None
asyncio.async(self.submit(self.pipeline.text(),
expinfo["file"], expinfo["experiment"],
dict(), self.priority.value(), due_date))