Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Rule] Detect WorksForMe Bugs #2362

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions bugbot/rules/worksforme.py
Original file line number Diff line number Diff line change
@@ -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] Bugs that could be resolved as WORKSFORME"

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()
4 changes: 4 additions & 0 deletions configs/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@
"max_days_in_cache": 7,
"days_lookup": 7
},
"worksforme": {
"max_days_in_cache": 30,
"days_lookup": 365
},
"stepstoreproduce": {
"max_days_in_cache": 7,
"days_lookup": 3,
Expand Down
3 changes: 3 additions & 0 deletions scripts/cron_run_daily.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions templates/worksforme.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<p>
The following {{ plural('bug is', data, pword='bugs are') }} probably worksforme and {{ plural('doesn\'t', data, pword='don\'t') }} have resolution value:
</p>
<table {{ table_attrs }}>
<thead>
<tr>
<th>Bug</th>
<th>Summary</th>
<th>Confidence (%)</th>
</tr>
</thead>
<tbody>
{% for i, (bugid, summary, confidence, autofixed) in enumerate(data) -%}
<tr {% if i % 2 == 0 %}bgcolor="#E0E0E0"
{% endif -%}
>
<td>
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id={{ bugid }}">{{ bugid }}</a>
</td>
<td>{{ summary | e }}</td>
<td {% if autofixed %}bgcolor="#00FF00"{% endif -%}>{{ confidence }}</td>
</tr>
{% endfor -%}
</tbody>
</table>