From 54d85efc2a1fc6f430458e66f3367c3a80e0ffd2 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 8 Aug 2015 11:08:04 +0800 Subject: [PATCH] master,gui: show Git commit messages in schedule --- artiq/gui/schedule.py | 9 +++++++-- artiq/gui/tools.py | 37 +++++++++++++++++++++++++++---------- artiq/master/repository.py | 10 ++++++---- artiq/master/scheduler.py | 14 ++++++++------ 4 files changed, 48 insertions(+), 22 deletions(-) diff --git a/artiq/gui/schedule.py b/artiq/gui/schedule.py index 69324e07a..ab11714c1 100644 --- a/artiq/gui/schedule.py +++ b/artiq/gui/schedule.py @@ -5,7 +5,7 @@ from quamash import QtGui, QtCore from pyqtgraph import dockarea from artiq.protocols.sync_struct import Subscriber -from artiq.gui.tools import DictSyncModel +from artiq.gui.tools import elide, DictSyncModel class _ScheduleModel(DictSyncModel): @@ -37,7 +37,10 @@ class _ScheduleModel(DictSyncModel): elif column == 5: expid = v["expid"] if "repo_rev" in expid: - return expid["repo_rev"] + r = expid["repo_rev"] + if v["repo_msg"]: + r += "\n" + elide(v["repo_msg"], 40) + return r else: return "Outside repo." elif column == 6: @@ -63,6 +66,8 @@ class ScheduleDock(dockarea.Dock): self.table.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) self.table.horizontalHeader().setResizeMode( QtGui.QHeaderView.ResizeToContents) + self.table.verticalHeader().setResizeMode( + QtGui.QHeaderView.ResizeToContents) self.addWidget(self.table) self.table.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) diff --git a/artiq/gui/tools.py b/artiq/gui/tools.py index ac003cf9c..7d673cc55 100644 --- a/artiq/gui/tools.py +++ b/artiq/gui/tools.py @@ -1,12 +1,24 @@ from quamash import QtCore -def force_spinbox_value(spinbox, value): - if spinbox.minimum() > value: - spinbox.setMinimum(value) - if spinbox.maximum() < value: - spinbox.setMaximum(value) - spinbox.setValue(value) +def elide(s, maxlen): + elided = False + if len(s) > maxlen: + s = s[:maxlen] + elided = True + try: + idx = s.index("\n") + except ValueError: + pass + else: + s = s[:idx] + elided = True + if elided: + maxlen -= 3 + if len(s) > maxlen: + s = s[:maxlen] + s += "..." + return s def short_format(v): @@ -16,10 +28,7 @@ def short_format(v): if t is int or t is float: return str(v) elif t is str: - if len(v) < 15: - return "\"" + v + "\"" - else: - return "\"" + v[:12] + "\"..." + return "\"" + elide(v, 15) + "\"" else: r = t.__name__ if t is list or t is dict or t is set: @@ -27,6 +36,14 @@ def short_format(v): return r +def force_spinbox_value(spinbox, value): + if spinbox.minimum() > value: + spinbox.setMinimum(value) + if spinbox.maximum() < value: + spinbox.setMaximum(value) + spinbox.setValue(value) + + class _SyncSubstruct: def __init__(self, update_cb, ref): self.update_cb = update_cb diff --git a/artiq/master/repository.py b/artiq/master/repository.py index 12e3f8a68..71eff04e1 100644 --- a/artiq/master/repository.py +++ b/artiq/master/repository.py @@ -70,7 +70,7 @@ class Repository: self._scanning = True new_head_rev = self.backend.get_head_rev() - wd = self.backend.request_rev(new_head_rev) + wd, _ = self.backend.request_rev(new_head_rev) self.backend.release_rev(self.head_rev) self.head_rev = new_head_rev new_explist = yield from _scan_experiments(wd, self.log_fn) @@ -90,7 +90,7 @@ class FilesystemBackend: return "N/A" def request_rev(self, rev): - return self.root + return self.root, None def release_rev(self, rev): pass @@ -99,7 +99,9 @@ class FilesystemBackend: class _GitCheckout: def __init__(self, git, rev): self.path = tempfile.mkdtemp() - git.checkout_tree(git.get(rev), directory=self.path) + commit = git.get(rev) + git.checkout_tree(commit, directory=self.path) + self.message = commit.message.strip() self.ref_count = 1 logger.info("checked out revision %s into %s", rev, self.path) @@ -126,7 +128,7 @@ class GitBackend: else: co = _GitCheckout(self.git, rev) self.checkouts[rev] = co - return co.path + return co.path, co.message def release_rev(self, rev): co = self.checkouts[rev] diff --git a/artiq/master/scheduler.py b/artiq/master/scheduler.py index 56751a926..fefa8539f 100644 --- a/artiq/master/scheduler.py +++ b/artiq/master/scheduler.py @@ -48,7 +48,7 @@ def _mk_worker_method(name): class Run: def __init__(self, rid, pipeline_name, wd, expid, priority, due_date, flush, - worker_handlers, notifier): + worker_handlers, notifier, **kwargs): # called through pool self.rid = rid self.pipeline_name = pipeline_name @@ -62,8 +62,7 @@ class Run: self._status = RunStatus.pending - self._notifier = notifier - self._notifier[self.rid] = { + notification = { "pipeline": self.pipeline_name, "expid": self.expid, "priority": self.priority, @@ -71,6 +70,9 @@ class Run: "flush": self.flush, "status": self._status.name } + notification.update(kwargs) + self._notifier = notifier + self._notifier[self.rid] = notification @property def status(self): @@ -142,11 +144,11 @@ class RunPool: if "repo_rev" in expid: if expid["repo_rev"] is None: expid["repo_rev"] = self._repo_backend.get_head_rev() - wd = self._repo_backend.request_rev(expid["repo_rev"]) + wd, repo_msg = self._repo_backend.request_rev(expid["repo_rev"]) else: - wd = None + wd, repo_msg = None, None run = Run(rid, pipeline_name, wd, expid, priority, due_date, flush, - self._worker_handlers, self._notifier) + self._worker_handlers, self._notifier, repo_msg=repo_msg) self.runs[rid] = run if self.submitted_cb is not None: self.submitted_cb()