def get_bugs(self, date="today", bug_ids=[]): self.query_url = "" # Ignore already analyzed commits. for commit in repository.get_commits(): pass rev_start = f"children({commit['node']})" commits = repository.download_commits(self.repo_dir, rev_start, ret=True) commits = [ commit for commit in commits if not commit["ever_backedout"] ] probs = self.model.classify(commits, True) indexes = probs.argmax(axis=-1) result = {} for commit, prob, index in zip(commits, probs, indexes): result[commit["node"]] = { "id": commit["node"], "summary": commit["desc"].split("\n", 1)[0], "result": "Risky" if prob[1] > 0.5 else "Not risky", "confidence": nice_round(prob[index]), } return result
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("regression", 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"}.issubset(bug_data.keys()): raise Exception(f"Invalid bug response {bug_id}: {bug_data!r}") bug = raw_bugs[bug_id] prob = bug_data["prob"] if prob[1] < 0.5: continue bug_id = str(bug_id) results[bug_id] = { "id": bug_id, "summary": bug["summary"], "confidence": nice_round(prob[1]), "autofixed": False, } # Only autofix results for which we are sure enough. if prob[1] >= self.get_config("confidence_threshold"): results[bug_id]["autofixed"] = True self.autofix_regression.append((bug_id, prob[1])) return results
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("stepstoreproduce", 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"}.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"] results[bug_id] = { "id": bug_id, "summary": bug["summary"], "has_str": "yes" if prob[1] > 0.5 else "no", "confidence": nice_round(prob[index]), "autofixed": False, } return results
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("spambug", bug_ids) 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"}.issubset(bug_data.keys()): raise Exception(f"Invalid bug response {bug_id}: {bug_data!r}") bug = raw_bugs[bug_id] prob = bug_data["prob"] if prob[1] < self.get_config("confidence_threshold"): continue self.autofix_bugs[bug_id] = { "id": bug_id, "summary": bug["summary"], "confidence": nice_round(prob[1]), } return self.autofix_bugs
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
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("component", 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"] conflated_components_mapping = bug_data["extra_data"][ "conflated_components_mapping"] # Skip product-only suggestions that are not useful. if "::" not in suggestion and bug["product"] == suggestion: continue suggestion = conflated_components_mapping.get( suggestion, suggestion) if "::" not in suggestion: logger.error( f"There is something wrong with this component suggestion! {suggestion}" ) continue i = suggestion.index("::") suggested_product = suggestion[:i] suggested_component = suggestion[i + 2:] # When moving bugs out of the 'General' component, we don't want to change the product (unless it is Firefox). if bug["component"] == "General" and bug["product"] not in { suggested_product, "Firefox", }: continue # Don't move bugs from Firefox::General to Core::Internationalization. if (bug["product"] == "Firefox" and bug["component"] == "General" and suggested_product == "Core" and suggested_component == "Internationalization"): continue bug_id = str(bug["id"]) result = { "id": bug_id, "summary": bug["summary"], "component": suggestion, "confidence": nice_round(prob[index]), "autofixed": False, } # In daily mode, we send an email with all results. if self.frequency == "daily": results[bug_id] = result confidence_threshold_conf = ("confidence_threshold" if bug["component"] != "General" else "general_confidence_threshold") if prob[index] >= self.get_config(confidence_threshold_conf): self.autofix_component[bug_id] = { "product": suggested_product, "component": suggested_component, } result["autofixed"] = True # In hourly mode, we send an email with only the bugs we acted upon. if self.frequency == "hourly": results[bug_id] = result return results