forked from M-Labs/artiq
1
0
Fork 0

browser: experiment dock cleanup

This commit is contained in:
Robert Jördens 2016-05-06 21:06:28 +02:00
parent ee8160863a
commit 47c7b04ac6
1 changed files with 19 additions and 39 deletions

View File

@ -4,6 +4,7 @@ import os
from functools import partial from functools import partial
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5 import QtCore, QtGui, QtWidgets
import h5py
from artiq import __artiq_dir__ as artiq_dir from artiq import __artiq_dir__ as artiq_dir
from artiq.gui.tools import LayoutWidget, log_level_to_name from artiq.gui.tools import LayoutWidget, log_level_to_name
@ -36,9 +37,9 @@ class _ArgumentEditor(QtWidgets.QTreeWidget):
set_resize_mode(1, QtWidgets.QHeaderView.Stretch) set_resize_mode(1, QtWidgets.QHeaderView.Stretch)
set_resize_mode(2, QtWidgets.QHeaderView.ResizeToContents) set_resize_mode(2, QtWidgets.QHeaderView.ResizeToContents)
self.header().setVisible(False) self.header().setVisible(False)
self.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection) self.setSelectionMode(self.NoSelection)
self.setHorizontalScrollMode(QtWidgets.QAbstractItemView.ScrollPerPixel) self.setHorizontalScrollMode(self.ScrollPerPixel)
self.setVerticalScrollMode(QtWidgets.QAbstractItemView.ScrollPerPixel) self.setVerticalScrollMode(self.ScrollPerPixel)
self.viewport().installEventFilter(_WheelFilter(self.viewport())) self.viewport().installEventFilter(_WheelFilter(self.viewport()))
@ -65,7 +66,8 @@ class _ArgumentEditor(QtWidgets.QTreeWidget):
recompute_argument = QtWidgets.QToolButton() recompute_argument = QtWidgets.QToolButton()
recompute_argument.setToolTip("Re-run the experiment's build " recompute_argument.setToolTip("Re-run the experiment's build "
"method and take the default value") "method and take the default value")
recompute_argument.setIcon(QtWidgets.QApplication.style().standardIcon( recompute_argument.setIcon(
QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_BrowserReload)) QtWidgets.QStyle.SP_BrowserReload))
recompute_argument.clicked.connect( recompute_argument.clicked.connect(
partial(self._recompute_argument_clicked, name)) partial(self._recompute_argument_clicked, name))
@ -76,7 +78,8 @@ class _ArgumentEditor(QtWidgets.QTreeWidget):
widget_item = QtWidgets.QTreeWidgetItem() widget_item = QtWidgets.QTreeWidgetItem()
self.addTopLevelItem(widget_item) self.addTopLevelItem(widget_item)
recompute_arguments = QtWidgets.QPushButton("Recompute all arguments") recompute_arguments = QtWidgets.QPushButton("Recompute all arguments")
recompute_arguments.setIcon(QtWidgets.QApplication.style().standardIcon( recompute_arguments.setIcon(
QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_BrowserReload)) QtWidgets.QStyle.SP_BrowserReload))
recompute_arguments.clicked.connect(self._recompute_arguments_clicked) recompute_arguments.clicked.connect(self._recompute_arguments_clicked)
@ -175,7 +178,7 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
self.layout.addWidget(self.argeditor, 0, 0, 1, 5) self.layout.addWidget(self.argeditor, 0, 0, 1, 5)
self.layout.setRowStretch(0, 1) self.layout.setRowStretch(0, 1)
options = self.get_submission_options() self.options = {"log_level": logging.WARNING}
log_level = QtWidgets.QComboBox() log_level = QtWidgets.QComboBox()
log_level.addItems(log_levels) log_level.addItems(log_levels)
@ -187,31 +190,14 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
self.layout.addWidget(log_level, 3, 1) self.layout.addWidget(log_level, 3, 1)
log_level.setCurrentIndex(log_levels.index( log_level.setCurrentIndex(log_levels.index(
log_level_to_name(options["log_level"]))) log_level_to_name(self.options["log_level"])))
def update_log_level(index): def update_log_level(index):
options["log_level"] = getattr(logging, log_level.currentText()) self.options["log_level"] = getattr(logging,
log_level.currentText())
log_level.currentIndexChanged.connect(update_log_level) log_level.currentIndexChanged.connect(update_log_level)
self.log_level = log_level self.log_level = log_level
if "repo_rev" in options:
repo_rev = QtWidgets.QLineEdit()
repo_rev.setPlaceholderText("current")
repo_rev_label = QtWidgets.QLabel("Revision:")
repo_rev_label.setToolTip("Experiment repository revision "
"(commit ID) to use")
self.layout.addWidget(repo_rev_label, 3, 2)
self.layout.addWidget(repo_rev, 3, 3)
if options["repo_rev"] is not None:
repo_rev.setText(options["repo_rev"])
def update_repo_rev(text):
if text:
options["repo_rev"] = text
else:
options["repo_rev"] = None
repo_rev.textChanged.connect(update_repo_rev)
self.repo_rev = repo_rev
submit = QtWidgets.QPushButton("Submit") submit = QtWidgets.QPushButton("Submit")
submit.setIcon(QtWidgets.QApplication.style().standardIcon( submit.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_DialogOkButton)) QtWidgets.QStyle.SP_DialogOkButton))
@ -232,9 +218,6 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
self.layout.addWidget(reqterm, 3, 4) self.layout.addWidget(reqterm, 3, 4)
reqterm.clicked.connect(self.reqterm_clicked) reqterm.clicked.connect(self.reqterm_clicked)
def get_submission_options(self):
return {"log_level": 10} # TODO
def submit_clicked(self): def submit_clicked(self):
try: try:
pass # TODO pass # TODO
@ -267,9 +250,6 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
try: try:
self.log_level.setCurrentIndex(log_levels.index( self.log_level.setCurrentIndex(log_levels.index(
log_level_to_name(expid["log_level"]))) log_level_to_name(expid["log_level"])))
if ("repo_rev" in expid and expid["repo_rev"] != "N/A" and
hasattr(self, "repo_rev")):
self.repo_rev.setText(expid["repo_rev"])
except: except:
logger.error("Could not set submission options from HDF5 expid", logger.error("Could not set submission options from HDF5 expid",
exc_info=True) exc_info=True)
@ -285,15 +265,15 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
return { return {
"argeditor": self.argeditor.save_state(), "argeditor": self.argeditor.save_state(),
"geometry": bytes(self.saveGeometry()), "geometry": bytes(self.saveGeometry()),
#"arguments": self.arguments, "expurl": self.expurl,
"expurl": self.expurl "options": self.options,
} }
def restore_state(self, state): def restore_state(self, state):
self.argeditor.restore_state(state["argeditor"]) self.argeditor.restore_state(state["argeditor"])
self.restoreGeometry(QtCore.QByteArray(state["geometry"])) self.restoreGeometry(QtCore.QByteArray(state["geometry"]))
#self.arguments = state["arguments"]
self.expurl = state["expurl"] self.expurl = state["expurl"]
self.options = state["options"]
class ExperimentsArea(QtWidgets.QMdiArea): class ExperimentsArea(QtWidgets.QMdiArea):
@ -329,7 +309,7 @@ class ExperimentsArea(QtWidgets.QMdiArea):
if self.open_experiments: if self.open_experiments:
raise NotImplementedError raise NotImplementedError
for ex_state in state["experiments"]: for ex_state in state["experiments"]:
ex = self.load_experiment(ex_state["file"]) ex = self.load_experiment(ex_state["expurl"])
ex.restore_state(ex_state) ex.restore_state(ex_state)
def open_experiment(self): def open_experiment(self):