Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b100770e05e2
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f010a74479a7
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Sep 14, 2016

  1. Copy the full SHA
    89417a4 View commit details
  2. Copy the full SHA
    55363e2 View commit details
  3. Copy the full SHA
    f010a74 View commit details
Showing with 83 additions and 28 deletions.
  1. +6 −6 artiq/browser/experiments.py
  2. +23 −13 artiq/dashboard/experiments.py
  3. +54 −9 artiq/gui/entries.py
12 changes: 6 additions & 6 deletions artiq/browser/experiments.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@

from artiq import __artiq_dir__ as artiq_dir
from artiq.gui.tools import LayoutWidget, log_level_to_name, get_open_file_name
from artiq.gui.entries import argty_to_entry
from artiq.gui.entries import procdesc_to_entry
from artiq.protocols import pyon
from artiq.master.worker import Worker, log_worker_exception

@@ -62,7 +62,7 @@ def __init__(self, dock):
widgets = dict()
self._arg_to_widgets[name] = widgets

entry = argty_to_entry[argument["desc"]["ty"]](argument)
entry = procdesc_to_entry(argument["desc"])(argument)
widget_item = QtWidgets.QTreeWidgetItem([name])
widgets["entry"] = entry
widgets["widget_item"] = widget_item
@@ -148,14 +148,14 @@ async def _recompute_argument(self, name):
argument = self._dock.arguments[name]

procdesc = arginfo[name][0]
state = argty_to_entry[procdesc["ty"]].default_state(procdesc)
state = procdesc_to_entry(procdesc).default_state(procdesc)
argument["desc"] = procdesc
argument["state"] = state

widgets = self._arg_to_widgets[name]

widgets["entry"].deleteLater()
widgets["entry"] = argty_to_entry[procdesc["ty"]](argument)
widgets["entry"] = procdesc_to_entry(procdesc)(argument)
widgets["fix_layout"] = LayoutWidget()
widgets["fix_layout"].addWidget(widgets["entry"])
self.setItemWidget(widgets["widget_item"], 1, widgets["fix_layout"])
@@ -318,7 +318,7 @@ def _run_clicked(self):
"class_name": class_name,
"log_level": self.options["log_level"],
"arguments": {
name: argty_to_entry[argument["desc"]["ty"]].state_to_value(
name: procdesc_to_entry(argument["desc"]).state_to_value(
argument["state"])
for name, argument in self.arguments.items()},
}
@@ -470,7 +470,7 @@ async def _select_experiment_task(self):
def initialize_submission_arguments(self, arginfo):
arguments = OrderedDict()
for name, (procdesc, group) in arginfo.items():
state = argty_to_entry[procdesc["ty"]].default_state(procdesc)
state = procdesc_to_entry(procdesc).default_state(procdesc)
arguments[name] = {
"desc": procdesc,
"group": group,
36 changes: 23 additions & 13 deletions artiq/dashboard/experiments.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
import h5py

from artiq.gui.tools import LayoutWidget, log_level_to_name, get_open_file_name
from artiq.gui.entries import argty_to_entry, ScanEntry
from artiq.gui.entries import procdesc_to_entry, ScanEntry
from artiq.protocols import pyon


@@ -71,7 +71,7 @@ def __init__(self, manager, dock, expurl):
widgets = dict()
self._arg_to_widgets[name] = widgets

entry = argty_to_entry[argument["desc"]["ty"]](argument)
entry = procdesc_to_entry(argument["desc"])(argument)
widget_item = QtWidgets.QTreeWidgetItem([name])
widgets["entry"] = entry
widgets["widget_item"] = widget_item
@@ -168,7 +168,7 @@ async def _recompute_argument(self, name):
argument = self.manager.get_submission_arguments(self.expurl)[name]

procdesc = arginfo[name][0]
state = argty_to_entry[procdesc["ty"]].default_state(procdesc)
state = procdesc_to_entry(procdesc).default_state(procdesc)
argument["desc"] = procdesc
argument["state"] = state

@@ -179,7 +179,7 @@ async def _recompute_argument(self, name):
widgets = self._arg_to_widgets[name]

widgets["entry"].deleteLater()
widgets["entry"] = argty_to_entry[procdesc["ty"]](argument)
widgets["entry"] = procdesc_to_entry(procdesc)(argument)
widgets["disable_other_scans"].setVisible(
isinstance(widgets["entry"], ScanEntry))
widgets["fix_layout"].deleteLater()
@@ -199,14 +199,18 @@ def save_state(self):
for k, v in self._groups.items():
if v.isExpanded():
expanded.append(k)
return {"expanded": expanded}
return {
"expanded": expanded,
"scroll": self.verticalScrollBar().value()
}

def restore_state(self, state):
for e in state["expanded"]:
try:
self._groups[e].setExpanded(True)
except KeyError:
pass
self.verticalScrollBar().setValue(state["scroll"])


log_levels = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
@@ -462,6 +466,7 @@ def __init__(self, main_window,
self.schedule_ctl = schedule_ctl
self.experiment_db_ctl = experiment_db_ctl

self.dock_states = dict()
self.submission_scheduling = dict()
self.submission_options = dict()
self.submission_arguments = dict()
@@ -519,7 +524,7 @@ def get_submission_options(self, expurl):
def initialize_submission_arguments(self, expurl, arginfo):
arguments = OrderedDict()
for name, (procdesc, group) in arginfo.items():
state = argty_to_entry[procdesc["ty"]].default_state(procdesc)
state = procdesc_to_entry(procdesc).default_state(procdesc)
arguments[name] = {
"desc": procdesc,
"group": group,
@@ -556,9 +561,13 @@ def open_experiment(self, expurl):
self.main_window.centralWidget().addSubWindow(dock)
dock.show()
dock.sigClosed.connect(partial(self.on_dock_closed, expurl))
if expurl in self.dock_states:
dock.restore_state(self.dock_states[expurl])
return dock

def on_dock_closed(self, expurl):
dock = self.open_experiments[expurl]
self.dock_states[expurl] = dock.save_state()
del self.open_experiments[expurl]

async def _submit_task(self, expurl, *args):
@@ -573,7 +582,7 @@ def submit(self, expurl):

argument_values = dict()
for name, argument in arguments.items():
entry_cls = argty_to_entry[argument["desc"]["ty"]]
entry_cls = procdesc_to_entry(argument["desc"])
argument_values[name] = entry_cls.state_to_value(argument["state"])

expid = {
@@ -639,21 +648,22 @@ async def open_file(self, file):
self.open_experiment(expurl)

def save_state(self):
docks = {expurl: dock.save_state()
for expurl, dock in self.open_experiments.items()}
for expurl, dock in self.open_experiments.items():
self.dock_states[expurl] = dock.save_state()
return {
"scheduling": self.submission_scheduling,
"options": self.submission_options,
"arguments": self.submission_arguments,
"docks": docks
"docks": self.dock_states,
"open_docks": set(self.open_experiments.keys())
}

def restore_state(self, state):
if self.open_experiments:
raise NotImplementedError
self.dock_states = state["docks"]
self.submission_scheduling = state["scheduling"]
self.submission_options = state["options"]
self.submission_arguments = state["arguments"]
for expurl, dock_state in state["docks"].items():
dock = self.open_experiment(expurl)
dock.restore_state(dock_state)
for expurl in state["open_docks"]:
self.open_experiment(expurl)
63 changes: 54 additions & 9 deletions artiq/gui/entries.py
Original file line number Diff line number Diff line change
@@ -69,7 +69,41 @@ def default_state(procdesc):
return procdesc["choices"][0]


class NumberEntry(ScientificSpinBox):
class NumberEntryInt(QtWidgets.QSpinBox):
def __init__(self, argument):
QtWidgets.QSpinBox.__init__(self)
disable_scroll_wheel(self)
procdesc = argument["desc"]
self.setSingleStep(procdesc["step"])
if procdesc["min"] is not None:
self.setMinimum(procdesc["min"])
else:
self.setMinimum(-((1 << 31) - 1))
if procdesc["max"] is not None:
self.setMaximum(procdesc["max"])
else:
self.setMaximum((1 << 31) - 1)
if procdesc["unit"]:
self.setSuffix(" " + procdesc["unit"])

self.setValue(argument["state"])
def update(value):
argument["state"] = value
self.valueChanged.connect(update)

@staticmethod
def state_to_value(state):
return state

@staticmethod
def default_state(procdesc):
if "default" in procdesc:
return procdesc["default"]
else:
return 0


class NumberEntryFloat(ScientificSpinBox):
def __init__(self, argument):
ScientificSpinBox.__init__(self)
disable_scroll_wheel(self)
@@ -149,6 +183,7 @@ def update_repetitions(value):
state["repetitions"] = value
self.repetitions.valueChanged.connect(update_repetitions)


class _RangeScan(LayoutWidget):
def __init__(self, procdesc, state):
LayoutWidget.__init__(self)
@@ -331,11 +366,21 @@ def _scan_type_toggled(self):
break


argty_to_entry = {
"PYONValue": StringEntry,
"BooleanValue": BooleanEntry,
"EnumerationValue": EnumerationEntry,
"NumberValue": NumberEntry,
"StringValue": StringEntry,
"Scannable": ScanEntry
}
def procdesc_to_entry(procdesc):
ty = procdesc["ty"]
if ty == "NumberValue":
is_int = (procdesc["ndecimals"] == 0
and int(procdesc["step"]) == procdesc["step"]
and procdesc["scale"] == 1)
if is_int:
return NumberEntryInt
else:
return NumberEntryFloat
else:
return {
"PYONValue": StringEntry,
"BooleanValue": BooleanEntry,
"EnumerationValue": EnumerationEntry,
"StringValue": StringEntry,
"Scannable": ScanEntry
}[ty]