| |
@@ -0,0 +1,88 @@
|
| |
+ #
|
| |
+ # retrace_server.py - Retrace server data parsers and utilities for packager dashboard
|
| |
+ #
|
| |
+ # Copyright 2021, Red Hat, Inc
|
| |
+ #
|
| |
+ # This program is free software; you can redistribute it and/or modify
|
| |
+ # it under the terms of the GNU General Public License as published by
|
| |
+ # the Free Software Foundation; either version 2 of the License, or
|
| |
+ # (at your option) any later version.
|
| |
+ #
|
| |
+ # This program is distributed in the hope that it will be useful,
|
| |
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| |
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| |
+ # GNU General Public License for more details.
|
| |
+ #
|
| |
+ # You should have received a copy of the GNU General Public License along
|
| |
+ # with this program; if not, write to the Free Software Foundation, Inc.,
|
| |
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
| |
+ #
|
| |
+ # Authors:
|
| |
+ # Frantisek Zatloukal <fzatlouk@redhat.com>
|
| |
+
|
| |
+ from collections import defaultdict
|
| |
+
|
| |
+ import datetime
|
| |
+ import statistics
|
| |
+
|
| |
+ from oraculum import app
|
| |
+ from oraculum.utils.dashboard_helpers import get_json
|
| |
+
|
| |
+ def fetch_retrace_data(package):
|
| |
+ """
|
| |
+ Returns {
|
| |
+ "retrace_link": "https://retrace.fedoraproject.org/faf/problems/?component_names=my_package&daterange=today-30:today"
|
| |
+ "problems_present": True/False, # Based on existence of any problems
|
| |
+ "outstanding_problems": [{ # List of problems with high (outlying) counts of occurences
|
| |
+ "id": 1111,
|
| |
+ "crash_function": "my_crashing_function",
|
| |
+ "count": 999,
|
| |
+ "url": "https://retrace.fedoraproject.org/faf/problems/1111"
|
| |
+ }, ...]
|
| |
+ }
|
| |
+ """
|
| |
+ now = datetime.date.today().isoformat()
|
| |
+ past = (datetime.date.today() - datetime.timedelta(days=30)).isoformat()
|
| |
+
|
| |
+ data = {
|
| |
+ "retrace_link": app.config["RETRACE_SERVER_URL"] + "?component_names=%s&daterange=%s:%s" % (package, past, now),
|
| |
+ "problems_present": False,
|
| |
+ "outstanding_problems": []
|
| |
+ }
|
| |
+ retrace_server_data = get_json(data["retrace_link"],
|
| |
+ headers={"Accept": "application/json", "Content-type": "application/json"})
|
| |
+ if len(retrace_server_data["problems"]) == 0:
|
| |
+ return data
|
| |
+
|
| |
+ # We have at least 1 problem, there may or may not be any outstanding issues
|
| |
+ data["problems_present"] = True
|
| |
+
|
| |
+ # To count occurences of a problem (by counting all the sub-issues together)
|
| |
+ occurences = defaultdict(lambda: 0)
|
| |
+
|
| |
+ for problem in retrace_server_data["problems"]:
|
| |
+ for report in problem["reports"]:
|
| |
+ occurences[problem["id"]] += report["count"]
|
| |
+
|
| |
+ # Count the threshold for occurences outliers (same algo as a box-plot uses)
|
| |
+ # We don't want to display/output every problem from the retrace server, just the extreme ones to filter out the noise
|
| |
+ if len(occurences) >= 2:
|
| |
+ occurences_quartiles = statistics.quantiles(occurences.values(), n=4)
|
| |
+ occurences_iqr = occurences_quartiles[2] - occurences_quartiles[0]
|
| |
+ occurences_outliers_threshold = occurences_quartiles[2] + 1.5 * occurences_iqr
|
| |
+ else:
|
| |
+ # If we have 1 problem we can't count quantiles, so let's output that problem by setting the threshold to 0
|
| |
+ occurences_outliers_threshold = 0
|
| |
+
|
| |
+ for problem in retrace_server_data["problems"]:
|
| |
+ cid = problem["id"]
|
| |
+ if occurences[cid] > occurences_outliers_threshold:
|
| |
+ data["outstanding_problems"].append({
|
| |
+ "id": cid,
|
| |
+ "crash_function": problem["crash_function"],
|
| |
+ "count": occurences[cid],
|
| |
+ "url": app.config["RETRACE_SERVER_URL"] + str(cid)
|
| |
+ })
|
| |
+
|
| |
+ return data
|
| |
+
|
| |
Fixes https://pagure.io/fedora-qa/packager_dashboard/issue/101