in bugbot/rules/defectenhancementtask.py [0:0]
def get_bugs(self, date="today", bug_ids=[]):
# Retrieve the bugs with the fields defined in get_bz_params
raw_bugs = super().get_bugs(date=date, bug_ids=bug_ids, chunk_size=7000)
if len(raw_bugs) == 0:
return {}
# Extract the bug ids
bug_ids = list(raw_bugs.keys())
# Classify those bugs
bugs = get_bug_ids_classification("defectenhancementtask", bug_ids)
results = {}
for bug_id in sorted(bugs.keys()):
bug_data = bugs[bug_id]
if not bug_data.get("available", True):
# The bug was not available, it was either removed or is a
# security bug
continue
if not {"prob", "index", "class", "extra_data"}.issubset(bug_data.keys()):
raise Exception(f"Invalid bug response {bug_id}: {bug_data!r}")
bug = raw_bugs[bug_id]
prob = bug_data["prob"]
index = bug_data["index"]
suggestion = bug_data["class"]
labels_map = bug_data["extra_data"]["labels_map"]
assert suggestion in {
"defect",
"enhancement",
"task",
}, f"Suggestion {suggestion} is invalid"
if bug["type"] == suggestion:
continue
defect_prob = prob[labels_map["defect"]]
enhancement_prob = prob[labels_map["enhancement"]]
task_prob = prob[labels_map["task"]]
results[bug_id] = {
"id": bug_id,
"summary": bug["summary"],
"type": bug["type"],
"bugbug_type": suggestion,
"confidence": nice_round(prob[index]),
"confidences": f"defect {nice_round(defect_prob)}, enhancement {nice_round(enhancement_prob)}, task {nice_round(task_prob)}",
"autofixed": False,
}
# Only autofix results for which we are sure enough.
# And only autofix defect -> task/enhancement for now, unless we're 100% sure.
"""if prob[index] == 1.0 or (
bug["type"] == "defect"
and (enhancement_prob + task_prob)
>= self.get_config("confidence_threshold")
):"""
if prob[index] == 1.0:
results[bug_id]["autofixed"] = True
self.autofix_type[bug["id"]] = suggestion
return results