forked from M-Labs/artiq
1
0
Fork 0

gui/experiments: support setting submission scheduling/options

This commit is contained in:
Sebastien Bourdeauducq 2015-11-30 17:18:31 +08:00
parent afa8148b2b
commit 24a33be9df
2 changed files with 68 additions and 26 deletions

View File

@ -8,6 +8,7 @@ from quamash import QtGui, QtCore
from pyqtgraph import dockarea from pyqtgraph import dockarea
from artiq.gui.scan import ScanController from artiq.gui.scan import ScanController
from artiq.gui.log import log_level_to_name
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -37,7 +38,7 @@ class _BooleanEntry(QtGui.QCheckBox):
QtGui.QCheckBox.__init__(self) QtGui.QCheckBox.__init__(self)
self.setChecked(argument["state"]) self.setChecked(argument["state"])
def update(checked): def update(checked):
argument["state"] = checked argument["state"] = bool(checked)
self.stateChanged.connect(update) self.stateChanged.connect(update)
@staticmethod @staticmethod
@ -175,7 +176,7 @@ class _ArgumentEditor(QtGui.QTreeWidget):
class _ExperimentDock(dockarea.Dock): class _ExperimentDock(dockarea.Dock):
def __init__(self, manager, expname): def __init__(self, manager, expname):
dockarea.Dock.__init__(self, "Experiment: " + expname, dockarea.Dock.__init__(self, "Exp: " + expname,
closable=True, size=(1500, 500)) closable=True, size=(1500, 500))
self.manager = manager self.manager = manager
self.expname = expname self.expname = expname
@ -184,34 +185,73 @@ class _ExperimentDock(dockarea.Dock):
manager.get_submission_arguments(expname)) manager.get_submission_arguments(expname))
self.addWidget(self.argeditor, 0, 0, colspan=4) self.addWidget(self.argeditor, 0, 0, colspan=4)
self.datetime = QtGui.QDateTimeEdit() scheduling = manager.get_submission_scheduling(expname)
self.datetime.setDisplayFormat("MMM d yyyy hh:mm:ss") options = manager.get_submission_options(expname)
self.datetime.setDate(QtCore.QDate.currentDate())
self.datetime.dateTimeChanged.connect(
lambda: self.datetime_en.setChecked(True))
self.datetime_en = QtGui.QCheckBox("Due date:")
self.addWidget(self.datetime_en, 1, 0, colspan=2)
self.addWidget(self.datetime, 1, 2, colspan=2)
self.pipeline = QtGui.QLineEdit() datetime = QtGui.QDateTimeEdit()
self.pipeline.setText("main") datetime.setDisplayFormat("MMM d yyyy hh:mm:ss")
datetime_en = QtGui.QCheckBox("Due date:")
self.addWidget(datetime_en, 1, 0, colspan=2)
self.addWidget(datetime, 1, 2, colspan=2)
if scheduling["due_date"] is None:
datetime.setDate(QtCore.QDate.currentDate())
else:
datetime.setDateTime(QtCore.QDateTime.fromMSecsSinceEpoch(
scheduling["due_date"]*1000))
datetime_en.setChecked(scheduling["due_date"] is not None)
def update_datetime(dt):
scheduling["due_date"] = dt.toMSecsSinceEpoch()/1000
datetime_en.setChecked(True)
datetime.dateTimeChanged.connect(update_datetime)
def update_datetime_en(checked):
if checked:
due_date = datetime.dateTime().toMSecsSinceEpoch()/1000
else:
due_date = None
scheduling["due_date"] = due_date
datetime_en.stateChanged.connect(update_datetime_en)
pipeline_name = QtGui.QLineEdit()
self.addWidget(QtGui.QLabel("Pipeline:"), 2, 0, colspan=2) self.addWidget(QtGui.QLabel("Pipeline:"), 2, 0, colspan=2)
self.addWidget(self.pipeline, 2, 2, colspan=2) self.addWidget(pipeline_name, 2, 2, colspan=2)
self.priority = QtGui.QSpinBox() pipeline_name.setText(scheduling["pipeline_name"])
self.priority.setRange(-99, 99) def update_pipeline_name():
scheduling["pipeline_name"] = pipeline_name.text()
pipeline_name.editingFinished.connect(update_pipeline_name)
priority = QtGui.QSpinBox()
priority.setRange(-99, 99)
self.addWidget(QtGui.QLabel("Priority:"), 3, 0) self.addWidget(QtGui.QLabel("Priority:"), 3, 0)
self.addWidget(self.priority, 3, 1) self.addWidget(priority, 3, 1)
self.flush = QtGui.QCheckBox("Flush") priority.setValue(scheduling["priority"])
self.flush.setToolTip("Flush the pipeline before starting the experiment") def update_priority(value):
self.addWidget(self.flush, 3, 2) scheduling["priority"] = value
priority.valueChanged.connect(update_priority)
self.log_level = QtGui.QComboBox() flush = QtGui.QCheckBox("Flush")
self.log_level.addItems(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]) flush.setToolTip("Flush the pipeline before starting the experiment")
self.log_level.setCurrentIndex(1) self.addWidget(flush, 3, 2)
self.log_level.setToolTip("Minimum level for log entry production")
self.addWidget(self.log_level, 3, 3) flush.setChecked(scheduling["flush"])
def update_flush(checked):
scheduling["flush"] = bool(checked)
flush.stateChanged.connect(update_flush)
log_level = QtGui.QComboBox()
log_levels = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
log_level.addItems(log_levels)
log_level.setCurrentIndex(1)
log_level.setToolTip("Minimum level for log entry production")
self.addWidget(log_level, 3, 3)
log_level.setCurrentIndex(log_levels.index(
log_level_to_name(options["log_level"])))
def update_log_level(index):
options["log_level"] = getattr(logging, log_level.currentText())
log_level.currentIndexChanged.connect(update_log_level)
submit = QtGui.QPushButton("Submit") submit = QtGui.QPushButton("Submit")
submit.setToolTip("Schedule the selected experiment (Ctrl+Return)") submit.setToolTip("Schedule the selected experiment (Ctrl+Return)")
@ -257,6 +297,7 @@ class ExperimentManager:
if expname in self.submission_scheduling: if expname in self.submission_scheduling:
return self.submission_scheduling[expname] return self.submission_scheduling[expname]
else: else:
# mutated by _ExperimentDock
scheduling = { scheduling = {
"pipeline_name": "main", "pipeline_name": "main",
"priority": 0, "priority": 0,
@ -270,6 +311,7 @@ class ExperimentManager:
if expname in self.submission_options: if expname in self.submission_options:
return self.submission_options[expname] return self.submission_options[expname]
else: else:
# mutated by _ExperimentDock
options = { options = {
"log_level": logging.WARNING, "log_level": logging.WARNING,
"repo_rev": None "repo_rev": None

View File

@ -12,7 +12,7 @@ except AttributeError:
QSortFilterProxyModel = QtGui.QSortFilterProxyModel QSortFilterProxyModel = QtGui.QSortFilterProxyModel
def _level_to_name(level): def log_level_to_name(level):
if level >= logging.CRITICAL: if level >= logging.CRITICAL:
return "CRITICAL" return "CRITICAL"
if level >= logging.ERROR: if level >= logging.ERROR:
@ -108,7 +108,7 @@ class Model(QtCore.QAbstractTableModel):
v = self.entries[index.row()] v = self.entries[index.row()]
column = index.column() column = index.column()
if column == 0: if column == 0:
return _level_to_name(v[0]) return log_level_to_name(v[0])
elif column == 1: elif column == 1:
return v[1] return v[1]
elif column == 2: elif column == 2: