From patchwork Thu Dec 3 21:20:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kanavin X-Patchwork-Id: 107228 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.3771.1796332864791262957 for ; Thu, 03 Dec 2026 13:21:05 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20260707 header.b=FBheX8kC; spf=pass (domain: gmail.com, ip: 209.85.128.47, mailfrom: alex.kanavin@gmail.com) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4b467581b98so1658545e9.0 for ; Thu, 03 Dec 2026 13:21:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796332863; x=1796937663; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=fkmvZxdmu1SULs31+gzELlCgt8krGDRh3utcVwKRJPE=; b=FBheX8kCpJBMVLmI6SIkEQsW5TuyjoXTYCfltxQuR4s+M7FslYrkS504sKYhPrwXBl eea5ZQt6XFcDlekYDnfRhyQQJx5oC5FLNdopi2VzwSEZXr0xbcWIyyiv+c7WPcxM3rm+ kY0yKTlzeIvo5gDMFYnJvZiYEZygdIDG/ys2PQmuTWWzegGkJZ98Dkfd5OIfjlSnkf/l TqU/sDw0ZtoKx+nzoRZ2E/yjzVxbDwkTBM12vbswhjpy2fOTC3w0jQ8ijLp5LI71hSzs gxFz9a4b+Yms1sXdtarGsT/U1sCmT4AwLmKWy0PyDWU1Zo96OL3O0CqaeoKL/UOahP2T H9BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796332863; x=1796937663; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=fkmvZxdmu1SULs31+gzELlCgt8krGDRh3utcVwKRJPE=; b=ok5/uennoRI+nLikCliyglyafQiZPGYY7+yJ8F7+ZOMrZJBsqfd2YIW0saqHb/dcVk b5drbltIreQI4yuJNYuBrVfzTOZWDdlNisxCBeXGjEyr9+wNM0qt6TxdS/CE0ra0TpzF JHlVbT7kl/Ee74XT43KkLxtgQuxMR2ay8cYYDtbiKHyuPgV/X20wrQ/loBfyTti3I6es IOHJOrSJj0sDNSAoEfyRUvnJiIQh1YWUPXZzX2yRJtDr3lRW6uUmmdO3gykmI9FQtD8Z XzSjU2HkaXH5n//zUoX0/aEzLUmZGNFf8ki5H6NxCzTuqMpcEZQg1midlFyiWY4C2UvR 3d9g== X-Gm-Message-State: APuU4Z82HJfSsMZQ3PJXZ1APZHdx6r/1VYpd3I0g1Xwp7nY80HTY518i xd7BU0iI2cMGJLCBoSMVKBJ3u2tJ0x4ND4IyjXvR3Fy5+KnKSff+sSI+tqVHSA== X-Gm-Gg: AZFdTZcH4X24wS0jyFL2jTCiuI6LWGuCOnA0MXosOi3e6BP7w6CSgrKPFvxzWh/ZT7w qlHvpuPv93+1iFHgJcvLA5XP3Q85qMGtLEMrQUsHez15qLugpA7H8RBclMpsP7EsMpwwM289ZXP 1Y6ki+DekIMjGsJaXDuMepCNOtK0kkQLCk5Ufq3pF/wx/bqUJUJBdNODc9iFzYFM9ToHmatiHAZ delRxZTwLhtn1aUKisdZNs/pkp1ieWu7bxMndIijAEXfcH7WBTFpQa6gYiYd0fJjHJYdX/oWBhl cWOPjkHxKSupiqAgzDQVHHDTw+tBLWLH7rKNQX37yIlAaGDYIKhAkwfxaJ16rOuIjbJ0ApdmhWO x9NvbV+gV/l4vRLh0fiArexEUo2DtHqRHrINXPHLd/sYUsd8qmODt12VCdl+GZSE0AEiMBKNIzx r95ZUjqIvwSmhP0ExffUYPVdvb8O0r8pwl6luT96X6MIf5WU5W0E+HlpR99f5qZIRaOgeZpPE98 T/QzmDPvXUd7k759frbpEjVQA5YMVGm6E6jTdTWLkrP6scOfJP70ZqDk1Qe544ku0JcfH2fh5V5 9UxPm28PgCby4Sr891cLdYW+U8nI3pKBsnlvSDGZmAkL2p7LM9WMXQY0oE3pZMA+ X-Received: by 2002:a05:600c:8b11:b0:4a2:a9:ed5a with SMTP id 5b1f17b1804b1-4bb88826835mr885487945e9.8.1796332863076; Thu, 03 Dec 2026 13:21:03 -0800 (PST) Return-Path: Received: from Zen2.lab.linutronix.de. (drugstore.linutronix.de. [80.153.143.164]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d1724ad3a5sm1860126f8f.9.2026.12.03.13.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 13:21:02 -0800 (PST) From: Alexander Kanavin X-Google-Original-From: Alexander Kanavin To: yocto-patches@lists.yoctoproject.org Cc: daniel.turull@ericsson.com, Alexander Kanavin Subject: [auh][PATCH v2 2/3] modules/statistics.py: rework and include first-seen statistics in status reports Date: Thu, 3 Dec 2026 22:20:49 +0100 Message-ID: <20261203212050.799982-2-alex@linutronix.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261203212050.799982-1-alex@linutronix.de> References: <20261203212050.799982-1-alex@linutronix.de> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Thu, 03 Dec 2026 21:21:06 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/5665 This module's code quality wasn't great (non-pythonic code, excessive amount of unneeded class data, producing a not particularly useful per-maintainer report), so I took the opportunity to clean it all up. Per-maintainer section of the report is dropped altogether. The status report now includes information about how long ago the current and new versions were first seen. This helps identify recipes which are falling behind upstream development: if either the current or new version was first seen many days ago, then updating that recipe should be prioritized: INFO: Recipe upgrade statistics: * Succeeded: 1 gpgme, 2.2.0 (first seen 117 day(s) ago) -> 2.3.1 (first seen 117 day(s) ago), Unassigned AI-Generated: Claude Sonnet 5.5 Signed-off-by: Alexander Kanavin --- modules/state.py | 14 +++++ modules/statistics.py | 116 +++++++++++++++++++++--------------------- upgrade-helper.py | 2 +- 3 files changed, 72 insertions(+), 60 deletions(-) diff --git a/modules/state.py b/modules/state.py index 9a10d32..1f3aebf 100644 --- a/modules/state.py +++ b/modules/state.py @@ -131,3 +131,17 @@ class State: return {'skip': True, 'reason': "%slast attempt %s result=%s; will retry in %d day(s)" % (prefix, when, result, retry_in)} + + def _firstseen_days(self, pn, field, version): + """Days since 'version' was first seen in 'field' (oldversion or + newversion); 0 if there is no matching state entry.""" + entry = self.data.get(pn) + if not entry or entry.get(field) != version: + return 0 + return int((time.time() - entry[field + '_firstseen']) / SECONDS_PER_DAY) + + def get_oldver_firstseen_days(self, pn, version): + return self._firstseen_days(pn, 'oldversion', version) + + def get_newver_firstseen_days(self, pn, version): + return self._firstseen_days(pn, 'newversion', version) diff --git a/modules/statistics.py b/modules/statistics.py index 5126a39..6174cec 100644 --- a/modules/statistics.py +++ b/modules/statistics.py @@ -25,16 +25,10 @@ class Statistics(object): def __init__(self): - self.succeeded = dict() - self.failed = dict() - self.succeeded["total"] = 0 - self.failed["total"] = 0 self.upgrade_stats = dict() - self.maintainers = set() - self.total_attempted = 0 self.skipped = [] - def _update(self, pn, new_ver, maintainer, error): + def _update(self, p, error): if error is None: status = "Succeeded" else: @@ -43,85 +37,89 @@ class Statistics(object): if not status in self.upgrade_stats: self.upgrade_stats[status] = [] - self.upgrade_stats[status].append((pn, new_ver, maintainer)) - - # add maintainer to the set of unique maintainers - self.maintainers.add(maintainer) - - if not maintainer in self.succeeded: - self.succeeded[maintainer] = 0 - if not maintainer in self.failed: - self.failed[maintainer] = 0 - - if status == "Succeeded": - self.succeeded["total"] += 1 - self.succeeded[maintainer] += 1 - else: - self.failed["total"] += 1 - self.failed[maintainer] += 1 - - self.total_attempted += 1 + self.upgrade_stats[status].append(p) def update(self, group): for p in group['pkgs']: - self._update(p['PN'],p['NPV'],p['MAINTAINER'],group['error']) + self._update(p, group['error']) def skip(self, group, reason): for p in group['pkgs']: - self.skipped.append((p['PN'],p['NPV'],p['MAINTAINER'],reason)) - - def _pkg_stats(self): + self.skipped.append((p, reason)) + + @property + def total_attempted(self): + return sum(len(v) for v in self.upgrade_stats.values()) + + @staticmethod + def _firstseen_days(state, p): + """(old version, new version) days since first seen; (0, 0) without state.""" + if state is None: + return (0, 0) + return (state.get_oldver_firstseen_days(p['PN'], p['PV']), + state.get_newver_firstseen_days(p['PN'], p['NPV'])) + + @staticmethod + def _pkg_line(p, old_days, new_days, state, reason=None): + """One report line; first-seen ages are only shown when state is in use.""" + if state is None: + line = "{}, {} -> {}".format(p['PN'], p['PV'], p['NPV']) + else: + line = "{}, {} (first seen {} day(s) ago) -> {} (first seen {} day(s) ago)".format( + p['PN'], p['PV'], old_days, p['NPV'], new_days) + if reason: + line += ", " + reason + if p['MAINTAINER']: + line += ", " + p['MAINTAINER'] + return " " + line + "\n" + + def _pkg_stats(self, state): stat_msg = "Recipe upgrade statistics:\n\n" for status in self.upgrade_stats: list_len = len(self.upgrade_stats[status]) if list_len > 0: - stat_msg += " * " + status + ": " + str(list_len) + "\n" + stat_msg += " * {}: {}\n".format(status, list_len) - for pkg, new_ver, maintainer in self.upgrade_stats[status]: - stat_msg += " " + pkg + ", " + new_ver - if maintainer: - stat_msg += ", " + maintainer - stat_msg += "\n" + for p in self.upgrade_stats[status]: + old_days, new_days = self._firstseen_days(state, p) + stat_msg += self._pkg_line(p, old_days, new_days, state) if self.skipped: stat_msg += " * Skipped: {}\n".format(len(self.skipped)) - for (pkg, new_ver, maintainer, reason) in self.skipped: - stat_msg += " {}, {}, {}, {}\n".format(pkg, new_ver, reason, maintainer) - if self.total_attempted == 0: - percent_succeded = 0 + skipped = [(p, reason) + self._firstseen_days(state, p) + for (p, reason) in self.skipped] + # Longest outstanding first + skipped.sort(key=lambda item: max(item[2], item[3]), reverse=True) + + for (p, reason, old_days, new_days) in skipped: + stat_msg += self._pkg_line(p, old_days, new_days, state, reason) + + attempted = self.total_attempted + succeeded = len(self.upgrade_stats.get('Succeeded', [])) + failed = attempted - succeeded + + if attempted == 0: + percent_succeeded = 0 percent_failed = 0 else: - percent_succeded = self.succeeded["total"] * 100.0 / self.total_attempted - percent_failed = self.failed["total"] * 100.0 / self.total_attempted + percent_succeeded = succeeded * 100.0 / attempted + percent_failed = failed * 100.0 / attempted stat_msg += "\n TOTAL: attempted=%d succeeded=%d(%.2f%%) failed=%d(%.2f%%)\n\n" % \ - (self.total_attempted, self.succeeded["total"], - percent_succeded, - self.failed["total"], + (attempted, succeeded, + percent_succeeded, + failed, percent_failed) return stat_msg - def _maintainer_stats(self): - stat_msg = "Recipe upgrade statistics per Maintainer:\n\n" - for m in self.maintainers: - attempted = self.succeeded[m] + self.failed[m] - stat_msg += " %s: attempted=%d succeeded=%d(%.2f%%) failed=%d(%.2f%%)\n" % \ - (m.split("@")[0] if m else "Maintainerless", attempted, self.succeeded[m], - self.succeeded[m] * 100.0 / attempted, - self.failed[m], - self.failed[m] * 100.0 / attempted) - - return stat_msg - - def get_summary(self, publish_work_url, workdir): + def get_summary(self, publish_work_url, workdir, state): msg = '' if publish_work_url: msg += "AUH finished upgrade batch the result patches/logs can be found at:\n" \ "%s/%s, next are the statistics:\n\n" % (publish_work_url, workdir) - msg += self._pkg_stats() - msg += self._maintainer_stats() + msg += self._pkg_stats(state) return msg diff --git a/upgrade-helper.py b/upgrade-helper.py index 8e47e40..6997e89 100755 --- a/upgrade-helper.py +++ b/upgrade-helper.py @@ -622,7 +622,7 @@ class Updater(object): attach_tarball = False statistics_summary = self.statistics.get_summary( - publish_work_url, os.path.basename(self.uh_work_dir)) + publish_work_url, os.path.basename(self.uh_work_dir), self.state) statistics_file = os.path.join(self.uh_work_dir, "statistics_summary")