forked from M-Labs/artiq
gui: datasets_sub -> dataset_sub (nfc)
This commit is contained in:
parent
0941d3a29a
commit
444bab2186
|
@ -24,7 +24,7 @@ class Model(DictSyncTreeSepModel):
|
||||||
|
|
||||||
|
|
||||||
class DatasetsDock(QtWidgets.QDockWidget):
|
class DatasetsDock(QtWidgets.QDockWidget):
|
||||||
def __init__(self, datasets_sub, master_host, master_port):
|
def __init__(self, dataset_sub, master_host, master_port):
|
||||||
QtWidgets.QDockWidget.__init__(self, "Datasets")
|
QtWidgets.QDockWidget.__init__(self, "Datasets")
|
||||||
self.setObjectName("Datasets")
|
self.setObjectName("Datasets")
|
||||||
self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable |
|
self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable |
|
||||||
|
@ -62,7 +62,7 @@ class DatasetsDock(QtWidgets.QDockWidget):
|
||||||
self.table.addAction(upload_action)
|
self.table.addAction(upload_action)
|
||||||
|
|
||||||
self.set_model(Model(dict()))
|
self.set_model(Model(dict()))
|
||||||
datasets_sub.add_setmodel_callback(self.set_model)
|
dataset_sub.add_setmodel_callback(self.set_model)
|
||||||
|
|
||||||
self.master_host = master_host
|
self.master_host = master_host
|
||||||
self.master_port = master_port
|
self.master_port = master_port
|
||||||
|
|
|
@ -378,9 +378,9 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
|
||||||
|
|
||||||
|
|
||||||
class LocalDatasetDB:
|
class LocalDatasetDB:
|
||||||
def __init__(self, datasets_sub):
|
def __init__(self, dataset_sub):
|
||||||
self.datasets_sub = datasets_sub
|
self.dataset_sub = dataset_sub
|
||||||
datasets_sub.add_setmodel_callback(self.init)
|
dataset_sub.add_setmodel_callback(self.init)
|
||||||
|
|
||||||
def init(self, data):
|
def init(self, data):
|
||||||
self._data = data
|
self._data = data
|
||||||
|
@ -389,11 +389,11 @@ class LocalDatasetDB:
|
||||||
return self._data.backing_store[key][1]
|
return self._data.backing_store[key][1]
|
||||||
|
|
||||||
def update(self, mod):
|
def update(self, mod):
|
||||||
self.datasets_sub.update(mod)
|
self.dataset_sub.update(mod)
|
||||||
|
|
||||||
|
|
||||||
class ExperimentsArea(QtWidgets.QMdiArea):
|
class ExperimentsArea(QtWidgets.QMdiArea):
|
||||||
def __init__(self, root, datasets_sub):
|
def __init__(self, root, dataset_sub):
|
||||||
QtWidgets.QMdiArea.__init__(self)
|
QtWidgets.QMdiArea.__init__(self)
|
||||||
self.pixmap = QtGui.QPixmap(os.path.join(
|
self.pixmap = QtGui.QPixmap(os.path.join(
|
||||||
artiq_dir, "gui", "logo_ver.svg"))
|
artiq_dir, "gui", "logo_ver.svg"))
|
||||||
|
@ -402,7 +402,7 @@ class ExperimentsArea(QtWidgets.QMdiArea):
|
||||||
|
|
||||||
self.open_experiments = []
|
self.open_experiments = []
|
||||||
|
|
||||||
self._ddb = LocalDatasetDB(datasets_sub)
|
self._ddb = LocalDatasetDB(dataset_sub)
|
||||||
|
|
||||||
self.worker_handlers = {
|
self.worker_handlers = {
|
||||||
"get_device_db": lambda: {},
|
"get_device_db": lambda: {},
|
||||||
|
|
|
@ -106,7 +106,7 @@ class Model(DictSyncTreeSepModel):
|
||||||
|
|
||||||
|
|
||||||
class DatasetsDock(QtWidgets.QDockWidget):
|
class DatasetsDock(QtWidgets.QDockWidget):
|
||||||
def __init__(self, datasets_sub, dataset_ctl):
|
def __init__(self, dataset_sub, dataset_ctl):
|
||||||
QtWidgets.QDockWidget.__init__(self, "Datasets")
|
QtWidgets.QDockWidget.__init__(self, "Datasets")
|
||||||
self.setObjectName("Datasets")
|
self.setObjectName("Datasets")
|
||||||
self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable |
|
self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable |
|
||||||
|
@ -146,7 +146,7 @@ class DatasetsDock(QtWidgets.QDockWidget):
|
||||||
self.table.addAction(delete_action)
|
self.table.addAction(delete_action)
|
||||||
|
|
||||||
self.table_model = Model(dict())
|
self.table_model = Model(dict())
|
||||||
datasets_sub.add_setmodel_callback(self.set_model)
|
dataset_sub.add_setmodel_callback(self.set_model)
|
||||||
|
|
||||||
def _search_datasets(self):
|
def _search_datasets(self):
|
||||||
if hasattr(self, "table_model_filter"):
|
if hasattr(self, "table_model_filter"):
|
||||||
|
|
|
@ -48,7 +48,7 @@ def get_argparser():
|
||||||
|
|
||||||
|
|
||||||
class Browser(QtWidgets.QMainWindow):
|
class Browser(QtWidgets.QMainWindow):
|
||||||
def __init__(self, smgr, datasets_sub, browse_root,
|
def __init__(self, smgr, dataset_sub, browse_root,
|
||||||
master_host, master_port, *, loop=None):
|
master_host, master_port, *, loop=None):
|
||||||
QtWidgets.QMainWindow.__init__(self)
|
QtWidgets.QMainWindow.__init__(self)
|
||||||
smgr.register(self)
|
smgr.register(self)
|
||||||
|
@ -65,7 +65,7 @@ class Browser(QtWidgets.QMainWindow):
|
||||||
self.setUnifiedTitleAndToolBarOnMac(True)
|
self.setUnifiedTitleAndToolBarOnMac(True)
|
||||||
|
|
||||||
self.experiments = experiments.ExperimentsArea(
|
self.experiments = experiments.ExperimentsArea(
|
||||||
browse_root, datasets_sub)
|
browse_root, dataset_sub)
|
||||||
smgr.register(self.experiments)
|
smgr.register(self.experiments)
|
||||||
self.experiments.setHorizontalScrollBarPolicy(
|
self.experiments.setHorizontalScrollBarPolicy(
|
||||||
QtCore.Qt.ScrollBarAsNeeded)
|
QtCore.Qt.ScrollBarAsNeeded)
|
||||||
|
@ -73,7 +73,7 @@ class Browser(QtWidgets.QMainWindow):
|
||||||
QtCore.Qt.ScrollBarAsNeeded)
|
QtCore.Qt.ScrollBarAsNeeded)
|
||||||
self.setCentralWidget(self.experiments)
|
self.setCentralWidget(self.experiments)
|
||||||
|
|
||||||
self.files = files.FilesDock(datasets_sub, browse_root)
|
self.files = files.FilesDock(dataset_sub, browse_root)
|
||||||
smgr.register(self.files)
|
smgr.register(self.files)
|
||||||
|
|
||||||
self.files.dataset_activated.connect(
|
self.files.dataset_activated.connect(
|
||||||
|
@ -81,12 +81,12 @@ class Browser(QtWidgets.QMainWindow):
|
||||||
self.files.dataset_changed.connect(
|
self.files.dataset_changed.connect(
|
||||||
self.experiments.dataset_changed)
|
self.experiments.dataset_changed)
|
||||||
|
|
||||||
self.applets = applets.AppletsDock(self, datasets_sub, loop=loop)
|
self.applets = applets.AppletsDock(self, dataset_sub, loop=loop)
|
||||||
smgr.register(self.applets)
|
smgr.register(self.applets)
|
||||||
atexit_register_coroutine(self.applets.stop, loop=loop)
|
atexit_register_coroutine(self.applets.stop, loop=loop)
|
||||||
|
|
||||||
self.datasets = datasets.DatasetsDock(
|
self.datasets = datasets.DatasetsDock(
|
||||||
datasets_sub, master_host, master_port)
|
dataset_sub, master_host, master_port)
|
||||||
smgr.register(self.datasets)
|
smgr.register(self.datasets)
|
||||||
self.files.metadata_changed.connect(self.datasets.metadata_changed)
|
self.files.metadata_changed.connect(self.datasets.metadata_changed)
|
||||||
|
|
||||||
|
@ -146,12 +146,12 @@ def main():
|
||||||
asyncio.set_event_loop(loop)
|
asyncio.set_event_loop(loop)
|
||||||
atexit.register(loop.close)
|
atexit.register(loop.close)
|
||||||
|
|
||||||
datasets_sub = models.LocalModelManager(datasets.Model)
|
dataset_sub = models.LocalModelManager(datasets.Model)
|
||||||
datasets_sub.init({})
|
dataset_sub.init({})
|
||||||
|
|
||||||
smgr = state.StateManager(args.db_file)
|
smgr = state.StateManager(args.db_file)
|
||||||
|
|
||||||
browser = Browser(smgr, datasets_sub, args.browse_root,
|
browser = Browser(smgr, dataset_sub, args.browse_root,
|
||||||
args.server, args.port, loop=loop)
|
args.server, args.port, loop=loop)
|
||||||
widget_log_handler.callback = browser.log.model.append
|
widget_log_handler.callback = browser.log.model.append
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,9 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class AppletIPCServer(AsyncioParentComm):
|
class AppletIPCServer(AsyncioParentComm):
|
||||||
def __init__(self, datasets_sub):
|
def __init__(self, dataset_sub):
|
||||||
AsyncioParentComm.__init__(self)
|
AsyncioParentComm.__init__(self)
|
||||||
self.datasets_sub = datasets_sub
|
self.dataset_sub = dataset_sub
|
||||||
self.datasets = set()
|
self.datasets = set()
|
||||||
self.dataset_prefixes = []
|
self.dataset_prefixes = []
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class AppletIPCServer(AsyncioParentComm):
|
||||||
self.write_pyon({"action": "mod", "mod": mod})
|
self.write_pyon({"action": "mod", "mod": mod})
|
||||||
|
|
||||||
async def serve(self, embed_cb, fix_initial_size_cb):
|
async def serve(self, embed_cb, fix_initial_size_cb):
|
||||||
self.datasets_sub.notify_cbs.append(self._on_mod)
|
self.dataset_sub.notify_cbs.append(self._on_mod)
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
obj = await self.read_pyon()
|
obj = await self.read_pyon()
|
||||||
|
@ -74,9 +74,9 @@ class AppletIPCServer(AsyncioParentComm):
|
||||||
elif action == "subscribe":
|
elif action == "subscribe":
|
||||||
self.datasets = obj["datasets"]
|
self.datasets = obj["datasets"]
|
||||||
self.dataset_prefixes = obj["dataset_prefixes"]
|
self.dataset_prefixes = obj["dataset_prefixes"]
|
||||||
if self.datasets_sub.model is not None:
|
if self.dataset_sub.model is not None:
|
||||||
mod = self._synthesize_init(
|
mod = self._synthesize_init(
|
||||||
self.datasets_sub.model.backing_store)
|
self.dataset_sub.model.backing_store)
|
||||||
self.write_pyon({"action": "mod", "mod": mod})
|
self.write_pyon({"action": "mod", "mod": mod})
|
||||||
else:
|
else:
|
||||||
raise ValueError("unknown action in applet message")
|
raise ValueError("unknown action in applet message")
|
||||||
|
@ -90,7 +90,7 @@ class AppletIPCServer(AsyncioParentComm):
|
||||||
logger.error("error processing data from applet, "
|
logger.error("error processing data from applet, "
|
||||||
"server stopped", exc_info=True)
|
"server stopped", exc_info=True)
|
||||||
finally:
|
finally:
|
||||||
self.datasets_sub.notify_cbs.remove(self._on_mod)
|
self.dataset_sub.notify_cbs.remove(self._on_mod)
|
||||||
|
|
||||||
def start_server(self, embed_cb, fix_initial_size_cb, *, loop=None):
|
def start_server(self, embed_cb, fix_initial_size_cb, *, loop=None):
|
||||||
self.server_task = asyncio.ensure_future(
|
self.server_task = asyncio.ensure_future(
|
||||||
|
@ -103,7 +103,7 @@ class AppletIPCServer(AsyncioParentComm):
|
||||||
|
|
||||||
|
|
||||||
class _AppletDock(QDockWidgetCloseDetect):
|
class _AppletDock(QDockWidgetCloseDetect):
|
||||||
def __init__(self, datasets_sub, uid, name, spec, extra_substitutes):
|
def __init__(self, dataset_sub, uid, name, spec, extra_substitutes):
|
||||||
QDockWidgetCloseDetect.__init__(self, "Applet: " + name)
|
QDockWidgetCloseDetect.__init__(self, "Applet: " + name)
|
||||||
self.setObjectName("applet" + str(uid))
|
self.setObjectName("applet" + str(uid))
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ class _AppletDock(QDockWidgetCloseDetect):
|
||||||
self.setMinimumSize(20*qfm.averageCharWidth(), 5*qfm.lineSpacing())
|
self.setMinimumSize(20*qfm.averageCharWidth(), 5*qfm.lineSpacing())
|
||||||
self.resize(40*qfm.averageCharWidth(), 10*qfm.lineSpacing())
|
self.resize(40*qfm.averageCharWidth(), 10*qfm.lineSpacing())
|
||||||
|
|
||||||
self.datasets_sub = datasets_sub
|
self.dataset_sub = dataset_sub
|
||||||
self.applet_name = name
|
self.applet_name = name
|
||||||
self.spec = spec
|
self.spec = spec
|
||||||
self.extra_substitutes = extra_substitutes
|
self.extra_substitutes = extra_substitutes
|
||||||
|
@ -130,7 +130,7 @@ class _AppletDock(QDockWidgetCloseDetect):
|
||||||
return
|
return
|
||||||
self.starting_stopping = True
|
self.starting_stopping = True
|
||||||
try:
|
try:
|
||||||
self.ipc = AppletIPCServer(self.datasets_sub)
|
self.ipc = AppletIPCServer(self.dataset_sub)
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env["PYTHONUNBUFFERED"] = "1"
|
env["PYTHONUNBUFFERED"] = "1"
|
||||||
env["ARTIQ_APPLET_EMBED"] = self.ipc.get_address()
|
env["ARTIQ_APPLET_EMBED"] = self.ipc.get_address()
|
||||||
|
@ -327,7 +327,7 @@ class _CompleterDelegate(QtWidgets.QStyledItemDelegate):
|
||||||
|
|
||||||
|
|
||||||
class AppletsDock(QtWidgets.QDockWidget):
|
class AppletsDock(QtWidgets.QDockWidget):
|
||||||
def __init__(self, main_window, datasets_sub, extra_substitutes={}, *, loop=None):
|
def __init__(self, main_window, dataset_sub, extra_substitutes={}, *, loop=None):
|
||||||
"""
|
"""
|
||||||
:param extra_substitutes: Map of extra ``${strings}`` to substitute in applet
|
:param extra_substitutes: Map of extra ``${strings}`` to substitute in applet
|
||||||
commands to their respective values.
|
commands to their respective values.
|
||||||
|
@ -338,7 +338,7 @@ class AppletsDock(QtWidgets.QDockWidget):
|
||||||
QtWidgets.QDockWidget.DockWidgetFloatable)
|
QtWidgets.QDockWidget.DockWidgetFloatable)
|
||||||
|
|
||||||
self.main_window = main_window
|
self.main_window = main_window
|
||||||
self.datasets_sub = datasets_sub
|
self.dataset_sub = dataset_sub
|
||||||
self.extra_substitutes = extra_substitutes
|
self.extra_substitutes = extra_substitutes
|
||||||
self.applet_uids = set()
|
self.applet_uids = set()
|
||||||
|
|
||||||
|
@ -364,7 +364,7 @@ class AppletsDock(QtWidgets.QDockWidget):
|
||||||
|
|
||||||
completer_delegate = _CompleterDelegate()
|
completer_delegate = _CompleterDelegate()
|
||||||
self.table.setItemDelegateForColumn(1, completer_delegate)
|
self.table.setItemDelegateForColumn(1, completer_delegate)
|
||||||
datasets_sub.add_setmodel_callback(completer_delegate.set_model)
|
dataset_sub.add_setmodel_callback(completer_delegate.set_model)
|
||||||
|
|
||||||
self.table.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
self.table.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||||
new_action = QtWidgets.QAction("New applet", self.table)
|
new_action = QtWidgets.QAction("New applet", self.table)
|
||||||
|
@ -440,7 +440,7 @@ class AppletsDock(QtWidgets.QDockWidget):
|
||||||
self.table.itemChanged.connect(self.item_changed)
|
self.table.itemChanged.connect(self.item_changed)
|
||||||
|
|
||||||
def create(self, item, name, spec):
|
def create(self, item, name, spec):
|
||||||
dock = _AppletDock(self.datasets_sub, item.applet_uid, name, spec, self.extra_substitutes)
|
dock = _AppletDock(self.dataset_sub, item.applet_uid, name, spec, self.extra_substitutes)
|
||||||
self.main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock)
|
self.main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock)
|
||||||
dock.setFloating(True)
|
dock.setFloating(True)
|
||||||
asyncio.ensure_future(dock.start(), loop=self._loop)
|
asyncio.ensure_future(dock.start(), loop=self._loop)
|
||||||
|
|
Loading…
Reference in New Issue