Skip to content

Commit

Permalink
gui/explorer: support requesting termination of all instances
Browse files Browse the repository at this point in the history
sbourdeauducq committed Nov 5, 2015
1 parent 976e136 commit a7c9c95
Showing 3 changed files with 44 additions and 3 deletions.
1 change: 1 addition & 0 deletions artiq/frontend/artiq_gui.py
Original file line number Diff line number Diff line change
@@ -116,6 +116,7 @@ def main():
loop.run_until_complete(d_schedule.sub_connect(
args.server, args.port_notify))
atexit.register(lambda: loop.run_until_complete(d_schedule.sub_close()))
d_explorer.get_current_schedule = d_schedule.get_current_schedule

d_log = LogDock()
smgr.register(d_log)
38 changes: 36 additions & 2 deletions artiq/gui/explorer.py
Original file line number Diff line number Diff line change
@@ -263,8 +263,7 @@ def __init__(self, main_window, status_bar, schedule_ctl, repository_ctl):
grid.addWidget(self.log_level, 3, 3)

submit = QtGui.QPushButton("Submit")
submit.setShortcut("CTRL+RETURN")
submit.setToolTip("Schedule the selected experiment (CTRL+ENTER)")
submit.setToolTip("Schedule the selected experiment (Ctrl+Return)")
grid.addWidget(submit, 4, 0, colspan=4)
submit.clicked.connect(self.submit_clicked)

@@ -276,6 +275,19 @@ def __init__(self, main_window, status_bar, schedule_ctl, repository_ctl):
self.shortcuts = ShortcutManager(self.main_window, self)

self.el.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
submit_action = QtGui.QAction("Submit", self.el)
submit_action.triggered.connect(self.submit_clicked)
submit_action.setShortcut("CTRL+RETURN")
self.el.addAction(submit_action)
reqterm_action = QtGui.QAction("Request termination of instances", self.el)
reqterm_action.triggered.connect(self.request_inst_term)
reqterm_action.setShortcut("CTRL+BACKSPACE")
self.el.addAction(reqterm_action)

sep = QtGui.QAction(self.el)
sep.setSeparator(True)
self.el.addAction(sep)

edit_shortcuts_action = QtGui.QAction("Edit shortcuts", self.el)
edit_shortcuts_action.triggered.connect(self.edit_shortcuts)
self.el.addAction(edit_shortcuts_action)
@@ -392,6 +404,28 @@ def submit_clicked(self):
due_date,
self.flush.isChecked())

async def request_term_multiple(self, rids):
for rid in rids:
try:
await self.schedule_ctl.request_termination(rid)
except:
pass

def request_inst_term(self):
if self.selected_key is not None:
expinfo = self.explist_model.backing_store[self.selected_key]
# attribute get_current_schedule must be set externally after
# instance creation
current_schedule = self.get_current_schedule()
rids = []
for rid, desc in current_schedule.items():
expid = desc["expid"]
if ("repo_rev" in expid # only consider runs from repository
and expid["file"] == expinfo["file"]
and expid["class_name"] == expinfo["class_name"]):
rids.append(rid)
asyncio.ensure_future(self.request_term_multiple(rids))

def edit_shortcuts(self):
experiments = sorted(self.explist_model.backing_store.keys())
self.shortcuts.edit(experiments)
8 changes: 7 additions & 1 deletion artiq/gui/schedule.py
Original file line number Diff line number Diff line change
@@ -82,14 +82,20 @@ def __init__(self, status_bar, schedule_ctl):
delete_action.setShortcut("SHIFT+DELETE")
self.table.addAction(delete_action)


async def sub_connect(self, host, port):
self.subscriber = Subscriber("schedule", self.init_schedule_model)
await self.subscriber.connect(host, port)

async def sub_close(self):
await self.subscriber.close()

def get_current_schedule(self):
try:
table_model = self.table_model
except AttributeError:
return dict()
return table_model.backing_store

def init_schedule_model(self, init):
self.table_model = _ScheduleModel(self.table, init)
self.table.setModel(self.table_model)

0 comments on commit a7c9c95

Please sign in to comment.