environment,dashboard: generalize multiple defaults, fix HDF5 argument load

This commit is contained in:
Sebastien Bourdeauducq 2016-05-24 08:58:34 -05:00
parent 43081b4f64
commit b3e55b753b
4 changed files with 14 additions and 3 deletions

View File

@ -331,7 +331,12 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
self.expurl, exc_info=True) self.expurl, exc_info=True)
return return
for k, v in overrides.items(): for k, v in overrides.items():
arginfo[k][0]["default"] = v # Some values (e.g. scans) may have multiple defaults in a list
if ("default" in arginfo[k][0]
and isinstance(arginfo[k][0]["default"], list)):
arginfo[k][0]["default"].insert(0, v)
else:
arginfo[k][0]["default"] = v
self.manager.initialize_submission_arguments(self.expurl, arginfo) self.manager.initialize_submission_arguments(self.expurl, arginfo)
self.argeditor.deleteLater() self.argeditor.deleteLater()

View File

@ -274,8 +274,10 @@ class _ScanEntry(LayoutWidget):
} }
if "default" in procdesc: if "default" in procdesc:
defaults = procdesc["default"] defaults = procdesc["default"]
if not isinstance(defaults, list):
defaults = [defaults]
state["selected"] = defaults[0]["ty"] state["selected"] = defaults[0]["ty"]
for default in defaults: for default in reversed(defaults):
ty = default["ty"] ty = default["ty"]
if ty == "NoScan": if ty == "NoScan":
state[ty]["value"] = default["value"] state[ty]["value"] = default["value"]

View File

@ -23,6 +23,10 @@ class DefaultMissing(Exception):
class _SimpleArgProcessor: class _SimpleArgProcessor:
def __init__(self, default=NoDefault): def __init__(self, default=NoDefault):
# If default is a list, it means multiple defaults are specified, with
# decreasing priority.
if isinstance(default, list):
raise NotImplementedError
if default is not NoDefault: if default is not NoDefault:
self.default_value = default self.default_value = default

View File

@ -166,7 +166,7 @@ class Scannable:
if global_step is None: if global_step is None:
global_step = scale/10.0 global_step = scale/10.0
if default is not NoDefault: if default is not NoDefault:
if not isinstance(default, (tuple, list)): if not isinstance(default, list):
default = [default] default = [default]
self.default_values = default self.default_values = default
self.unit = unit self.unit = unit