2019-01-15 05:01:57 +03:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# 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/.
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import csv
|
|
|
|
import os
|
|
|
|
import random
|
|
|
|
|
|
|
|
from bugbug import bugzilla
|
2019-05-16 16:34:38 +03:00
|
|
|
from bugbug.models import load_model
|
2019-01-15 05:01:57 +03:00
|
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
2019-04-09 16:57:29 +03:00
|
|
|
parser.add_argument(
|
|
|
|
"--goal",
|
|
|
|
help="Goal of the labeler",
|
|
|
|
choices=["str", "regressionrange"],
|
|
|
|
default="str",
|
|
|
|
)
|
2019-01-15 05:01:57 +03:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
2019-04-09 16:57:29 +03:00
|
|
|
if args.goal == "str":
|
2019-05-16 16:34:38 +03:00
|
|
|
model = load_model("bug")
|
2019-04-09 16:57:29 +03:00
|
|
|
elif args.goal == "regressionrange":
|
2019-05-16 16:34:38 +03:00
|
|
|
model = load_model("regression")
|
2019-04-09 16:57:29 +03:00
|
|
|
|
|
|
|
file_path = os.path.join("bugbug", "labels", f"{args.goal}.csv")
|
2019-01-15 05:01:57 +03:00
|
|
|
|
2019-04-09 16:57:29 +03:00
|
|
|
with open(file_path, "r") as f:
|
2019-01-15 05:01:57 +03:00
|
|
|
reader = csv.reader(f)
|
|
|
|
next(reader)
|
|
|
|
labeled_comments = [(int(r[0]), int(r[1]), r[2]) for r in reader]
|
|
|
|
|
|
|
|
already_done = set((c[0], c[1]) for c in labeled_comments)
|
|
|
|
|
|
|
|
bugs = []
|
|
|
|
for bug in bugzilla.get_bugs():
|
|
|
|
# For the str and regressionrange problems, we don't care about test failures,
|
2019-04-09 16:57:29 +03:00
|
|
|
if (
|
|
|
|
"intermittent-failure" in bug["keywords"]
|
|
|
|
or "stockwell" in bug["whiteboard"]
|
|
|
|
or "permafail" in bug["summary"].lower()
|
|
|
|
):
|
2019-01-15 05:01:57 +03:00
|
|
|
continue
|
|
|
|
|
|
|
|
# bugs filed from Socorro,
|
2019-04-09 16:57:29 +03:00
|
|
|
if (
|
|
|
|
"this bug was filed from the socorro interface"
|
|
|
|
in bug["comments"][0]["text"].lower()
|
|
|
|
):
|
2019-01-15 05:01:57 +03:00
|
|
|
continue
|
|
|
|
|
|
|
|
# and fuzzing bugs.
|
2019-04-09 16:57:29 +03:00
|
|
|
if "fuzzing" in bug["comments"][0]["text"].lower():
|
2019-01-15 05:01:57 +03:00
|
|
|
continue
|
|
|
|
|
|
|
|
bugs.append(bug)
|
|
|
|
|
|
|
|
random.shuffle(bugs)
|
|
|
|
|
|
|
|
for bug in bugs:
|
|
|
|
# Only show bugs that are really bugs/regressions for labeling.
|
|
|
|
c = model.classify(bug)
|
|
|
|
if c != 1:
|
|
|
|
continue
|
|
|
|
|
|
|
|
v = None
|
|
|
|
|
2019-04-09 16:57:29 +03:00
|
|
|
for i, comment in enumerate(bug["comments"]):
|
|
|
|
if (bug["id"], i) in already_done:
|
2019-01-15 05:01:57 +03:00
|
|
|
continue
|
|
|
|
|
2019-04-09 16:57:29 +03:00
|
|
|
os.system("clear")
|
2019-01-21 00:30:34 +03:00
|
|
|
print(f'Bug {bug["id"]} - {bug["summary"]}')
|
2019-04-09 16:57:29 +03:00
|
|
|
print(f"Comment {i}")
|
|
|
|
print(comment["text"])
|
|
|
|
|
|
|
|
if args.goal == "str":
|
|
|
|
print(
|
|
|
|
"\nY for comment containing STR, N for comment not containing STR, K to skip, E to exit"
|
|
|
|
)
|
|
|
|
elif args.goal == "regressionrange":
|
|
|
|
print(
|
|
|
|
"\nY for comment containing regression range, N for comment not containing regression range, K to skip, E to exit"
|
|
|
|
)
|
2019-01-15 05:01:57 +03:00
|
|
|
v = input()
|
|
|
|
|
2019-04-09 16:57:29 +03:00
|
|
|
if v in ["e", "k"]:
|
2019-01-15 05:01:57 +03:00
|
|
|
break
|
|
|
|
|
2019-04-09 16:57:29 +03:00
|
|
|
if v in ["y", "n"]:
|
|
|
|
labeled_comments.append((bug["id"], i, v))
|
2019-01-15 05:01:57 +03:00
|
|
|
|
2019-04-09 16:57:29 +03:00
|
|
|
if v not in ["e", "k"]:
|
|
|
|
with open(file_path, "w") as f:
|
2019-01-15 05:01:57 +03:00
|
|
|
writer = csv.writer(f)
|
2019-04-09 16:57:29 +03:00
|
|
|
writer.writerow(["bug_id", "comment_num", f"has_{args.goal}"])
|
2019-01-15 05:01:57 +03:00
|
|
|
writer.writerows(sorted(labeled_comments))
|
|
|
|
|
2019-04-09 16:57:29 +03:00
|
|
|
print("\nE to exit, anything else to continue")
|
2019-01-15 05:01:57 +03:00
|
|
|
v = input()
|
|
|
|
|
2019-04-09 16:57:29 +03:00
|
|
|
if v == "e":
|
2019-01-15 05:01:57 +03:00
|
|
|
break
|