From 0a9878ed7272673afbcbd519ccd0936ba0639fcf Mon Sep 17 00:00:00 2001 From: Promise Fru Date: Thu, 29 Feb 2024 06:53:36 -0600 Subject: [PATCH 1/3] Add worksforme bot rule --- bugbot/rules/worksforme.py | 79 ++++++++++++++++++++++++++++++++++++++ configs/rules.json | 4 ++ scripts/cron_run_daily.sh | 3 ++ templates/worksforme.html | 25 ++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 bugbot/rules/worksforme.py create mode 100644 templates/worksforme.html diff --git a/bugbot/rules/worksforme.py b/bugbot/rules/worksforme.py new file mode 100644 index 000000000..7505d7f91 --- /dev/null +++ b/bugbot/rules/worksforme.py @@ -0,0 +1,79 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + +from bugbot.bugbug_utils import get_bug_ids_classification +from bugbot.bzcleaner import BzCleaner +from bugbot.utils import nice_round + + +class WorksForMe(BzCleaner): + def __init__(self, confidence_threshold: float = 0.9): + """ + Initialize the WorksForMe class. + + Args: + confidence_threshold: The confidence threshold for + considering a bug as a worksforme bug. + """ + super().__init__() + self.confidence_threshold = confidence_threshold + + def description(self): + return "[Using ML] Potential Worksforme Bugs with Missing Resolution" + + def columns(self): + return ["id", "summary", "confidence", "autofixed"] + + def get_bz_params(self, date): + start_date, _ = self.get_dates(date) + + params = { + "resolution": "---", + "cf_last_resolved": "---", + "f1": "creation_ts", + "o1": "greaterthan", + "v1": start_date, + "f2": "resolution", + "o2": "notequals", + "v2": "WORKSFORME", + } + + return params + + def get_bugs(self, date="today", bug_ids=[]): + raw_bugs = super().get_bugs(date=date, bug_ids=bug_ids, chunk_size=7000) + + if len(raw_bugs) == 0: + return {} + + bug_ids = list(raw_bugs.keys()) + + bugs = get_bug_ids_classification("worksforme", bug_ids) + + results = {} + + for bug_id, bug_data in bugs.items(): + if not bug_data.get("available", True): + # The bug was not available, it was either removed or is a + # security bug + continue + + bug = raw_bugs[bug_id] + prob = bug_data["prob"] + + if prob[1] < 0.2: + continue + + results[bug_id] = { + "id": bug_id, + "summary": bug["summary"], + "confidence": nice_round(prob[1]), + "autofixed": prob[1] >= self.confidence_threshold, + } + + return results + + +if __name__ == "__main__": + WorksForMe().run() diff --git a/configs/rules.json b/configs/rules.json index 3fca4a8c1..6599450dc 100644 --- a/configs/rules.json +++ b/configs/rules.json @@ -416,6 +416,10 @@ "max_days_in_cache": 7, "days_lookup": 7 }, + "worksforme": { + "max_days_in_cache": 7, + "days_lookup": 7 + }, "stepstoreproduce": { "max_days_in_cache": 7, "days_lookup": 3, diff --git a/scripts/cron_run_daily.sh b/scripts/cron_run_daily.sh index 86f63b8b8..5bbd41db3 100755 --- a/scripts/cron_run_daily.sh +++ b/scripts/cron_run_daily.sh @@ -15,6 +15,9 @@ python -m bugbot.rules.accessibilitybug --production # Try to detect potential performance-related bugs using bugbug python -m bugbot.rules.performancebug --production +# Try to detect potential worksforme bugs using bugbug +python -m bugbot.rules.worksforme --production + # Send a mail if the logs are not empty # MUST ALWAYS BE THE LAST COMMAND python -m bugbot.log --send diff --git a/templates/worksforme.html b/templates/worksforme.html new file mode 100644 index 000000000..19a947ec7 --- /dev/null +++ b/templates/worksforme.html @@ -0,0 +1,25 @@ +

+ The following {{ plural('bug is', data, pword='bugs are') }} probably worksforme and {{ plural('doesn\'t', data, pword='don\'t') }} have resolution value: +

+ + + + + + + + + + {% for i, (bugid, summary, confidence, autofixed) in enumerate(data) -%} + + + + + + {% endfor -%} + +
BugSummaryConfidence (%)
+ {{ bugid }} + {{ summary | e }}{{ confidence }}
From c7c8e4b74a3b554c17759a1942c2dad8d8ec243c Mon Sep 17 00:00:00 2001 From: Promise Fru <33162641+PromiseFru@users.noreply.github.com> Date: Mon, 4 Mar 2024 11:45:58 +0100 Subject: [PATCH 2/3] Update bugbot/rules/worksforme.py Co-authored-by: Suhaib Mujahid --- bugbot/rules/worksforme.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bugbot/rules/worksforme.py b/bugbot/rules/worksforme.py index 7505d7f91..aee572521 100644 --- a/bugbot/rules/worksforme.py +++ b/bugbot/rules/worksforme.py @@ -20,7 +20,7 @@ def __init__(self, confidence_threshold: float = 0.9): self.confidence_threshold = confidence_threshold def description(self): - return "[Using ML] Potential Worksforme Bugs with Missing Resolution" + return "[Using ML] Bugs that could be resolved as WORKSFORME" def columns(self): return ["id", "summary", "confidence", "autofixed"] From 664752dfeb637e78fe05b7307a5e6a859b40bda5 Mon Sep 17 00:00:00 2001 From: Promise Fru Date: Mon, 4 Mar 2024 05:22:12 -0600 Subject: [PATCH 3/3] Updated rules configuration to target bugs created within the past year but untouched in the last month. --- configs/rules.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configs/rules.json b/configs/rules.json index 6599450dc..285cc9c22 100644 --- a/configs/rules.json +++ b/configs/rules.json @@ -417,8 +417,8 @@ "days_lookup": 7 }, "worksforme": { - "max_days_in_cache": 7, - "days_lookup": 7 + "max_days_in_cache": 30, + "days_lookup": 365 }, "stepstoreproduce": { "max_days_in_cache": 7,