prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Add an option to the bug_classifier script to classify a specific bug
  
  
  </issue>
  <code>
  [start of scripts/bug_classifier.py]
  1 # -*- coding: utf-8 -*-
  2 
  3 import argparse
  4 import os
  5 from logging import INFO, basicConfig, getLogger
  6 
  7 import numpy as np
  8 import requests
  9 
  10 from bugbug import bugzilla
  11 from bugbug.models import get_model_class
  12 from bugbug.utils import download_check_etag, zstd_decompress
  13 
  14 MODELS_WITH_TYPE = ("component",)
  15 
  16 basicConfig(level=INFO)
  17 logger = getLogger(__name__)
  18 
  19 
  20 def classify_bugs(model_name, classifier):
  21     if classifier != "default":
  22         assert (
  23             model_name in MODELS_WITH_TYPE
  24         ), f"{classifier} is not a valid classifier type for {model_name}"
  25 
  26         model_file_name = f"{model_name}{classifier}model"
  27         model_name = f"{model_name}_{classifier}"
  28     else:
  29         model_file_name = f"{model_name}model"
  30 
  31     if not os.path.exists(model_file_name):
  32         logger.info(f"{model_file_name} does not exist. Downloading the model....")
  33         try:
  34             download_check_etag(
  35                 f"https://index.taskcluster.net/v1/task/project.relman.bugbug.train_{model_name}.latest/artifacts/public/{model_file_name}.zst",
  36                 f"{model_file_name}.zst",
  37             )
  38         except requests.HTTPError:
  39             logger.error(
  40                 f"A pre-trained model is not available, you will need to train it yourself using the trainer script"
  41             )
  42             raise SystemExit(1)
  43 
  44         zstd_decompress(model_file_name)
  45         assert os.path.exists(model_file_name), "Decompressed file doesn't exist"
  46 
  47     model_class = get_model_class(model_name)
  48     model = model_class.load(model_file_name)
  49 
  50     for bug in bugzilla.get_bugs():
  51         print(
  52             f'https://bugzilla.mozilla.org/show_bug.cgi?id={bug["id"]} - {bug["summary"]} '
  53         )
  54 
  55         if model.calculate_importance:
  56             probas, importance = model.classify(
  57                 bug, probabilities=True, importances=True
  58             )
  59 
  60             feature_names = model.get_human_readable_feature_names()
  61 
  62             model.print_feature_importances(
  63                 importance["importances"], feature_names, class_probabilities=probas
  64             )
  65         else:
  66             probas = model.classify(bug, probabilities=True, importances=False)
  67 
  68         if np.argmax(probas) == 1:
  69             print(f"Positive! {probas}")
  70         else:
  71             print(f"Negative! {probas}")
  72         input()
  73 
  74 
  75 def main():
  76     description = "Perform evaluation on bugs using the specified model"
  77     parser = argparse.ArgumentParser(description=description)
  78 
  79     parser.add_argument("model", help="Which model to use for evaluation")
  80     parser.add_argument(
  81         "--classifier",
  82         help="Type of the classifier. Only used for component classification.",
  83         choices=["default", "nn"],
  84         default="default",
  85     )
  86 
  87     args = parser.parse_args()
  88 
  89     classify_bugs(args.model, args.classifier)
  90
  [end of scripts/bug_classifier.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/scripts/bug_classifier.py b/scripts/bug_classifier.py
  --- a/scripts/bug_classifier.py
  +++ b/scripts/bug_classifier.py
  @@ -17,7 +17,7 @@
   logger = getLogger(__name__)
   
   
  -def classify_bugs(model_name, classifier):
  +def classify_bugs(model_name, classifier, bug_id):
       if classifier != "default":
           assert (
               model_name in MODELS_WITH_TYPE
  @@ -47,7 +47,13 @@
       model_class = get_model_class(model_name)
       model = model_class.load(model_file_name)
   
  -    for bug in bugzilla.get_bugs():
  +    if bug_id:
  +        bugs = bugzilla.get(bug_id).values()
  +        assert bugs, f"A bug with a bug id of {bug_id} was not found"
  +    else:
  +        bugs = bugzilla.get_bugs()
  +
  +    for bug in bugs:
           print(
               f'https://bugzilla.mozilla.org/show_bug.cgi?id={bug["id"]} - {bug["summary"]} '
           )
  @@ -83,7 +89,8 @@
           choices=["default", "nn"],
           default="default",
       )
  +    parser.add_argument("--bug-id", help="Classify the given bug id")
   
       args = parser.parse_args()
   
  -    classify_bugs(args.model, args.classifier)
  +    classify_bugs(args.model, args.classifier, args.bug_id)
  
verification_info: {"golden_diff": "diff --git a/scripts/bug_classifier.py b/scripts/bug_classifier.py\n--- a/scripts/bug_classifier.py\n+++ b/scripts/bug_classifier.py\n@@ -17,7 +17,7 @@\n logger = getLogger(__name__)\n \n \n-def classify_bugs(model_name, classifier):\n+def classify_bugs(model_name, classifier, bug_id):\n     if classifier != \"default\":\n         assert (\n             model_name in MODELS_WITH_TYPE\n@@ -47,7 +47,13 @@\n     model_class = get_model_class(model_name)\n     model = model_class.load(model_file_name)\n \n-    for bug in bugzilla.get_bugs():\n+    if bug_id:\n+        bugs = bugzilla.get(bug_id).values()\n+        assert bugs, f\"A bug with a bug id of {bug_id} was not found\"\n+    else:\n+        bugs = bugzilla.get_bugs()\n+\n+    for bug in bugs:\n         print(\n             f'https://bugzilla.mozilla.org/show_bug.cgi?id={bug[\"id\"]} - {bug[\"summary\"]} '\n         )\n@@ -83,7 +89,8 @@\n         choices=[\"default\", \"nn\"],\n         default=\"default\",\n     )\n+    parser.add_argument(\"--bug-id\", help=\"Classify the given bug id\")\n \n     args = parser.parse_args()\n \n-    classify_bugs(args.model, args.classifier)\n+    classify_bugs(args.model, args.classifier, args.bug_id)\n", "issue": "Add an option to the bug_classifier script to classify a specific bug\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\nimport argparse\nimport os\nfrom logging import INFO, basicConfig, getLogger\n\nimport numpy as np\nimport requests\n\nfrom bugbug import bugzilla\nfrom bugbug.models import get_model_class\nfrom bugbug.utils import download_check_etag, zstd_decompress\n\nMODELS_WITH_TYPE = (\"component\",)\n\nbasicConfig(level=INFO)\nlogger = getLogger(__name__)\n\n\ndef classify_bugs(model_name, classifier):\n    if classifier != \"default\":\n        assert (\n            model_name in MODELS_WITH_TYPE\n        ), f\"{classifier} is not a valid classifier type for {model_name}\"\n\n        model_file_name = f\"{model_name}{classifier}model\"\n        model_name = f\"{model_name}_{classifier}\"\n    else:\n        model_file_name = f\"{model_name}model\"\n\n    if not os.path.exists(model_file_name):\n        logger.info(f\"{model_file_name} does not exist. Downloading the model....\")\n        try:\n            download_check_etag(\n                f\"https://index.taskcluster.net/v1/task/project.relman.bugbug.train_{model_name}.latest/artifacts/public/{model_file_name}.zst\",\n                f\"{model_file_name}.zst\",\n            )\n        except requests.HTTPError:\n            logger.error(\n                f\"A pre-trained model is not available, you will need to train it yourself using the trainer script\"\n            )\n            raise SystemExit(1)\n\n        zstd_decompress(model_file_name)\n        assert os.path.exists(model_file_name), \"Decompressed file doesn't exist\"\n\n    model_class = get_model_class(model_name)\n    model = model_class.load(model_file_name)\n\n    for bug in bugzilla.get_bugs():\n        print(\n            f'https://bugzilla.mozilla.org/show_bug.cgi?id={bug[\"id\"]} - {bug[\"summary\"]} '\n        )\n\n        if model.calculate_importance:\n            probas, importance = model.classify(\n                bug, probabilities=True, importances=True\n            )\n\n            feature_names = model.get_human_readable_feature_names()\n\n            model.print_feature_importances(\n                importance[\"importances\"], feature_names, class_probabilities=probas\n            )\n        else:\n            probas = model.classify(bug, probabilities=True, importances=False)\n\n        if np.argmax(probas) == 1:\n            print(f\"Positive! {probas}\")\n        else:\n            print(f\"Negative! {probas}\")\n        input()\n\n\ndef main():\n    description = \"Perform evaluation on bugs using the specified model\"\n    parser = argparse.ArgumentParser(description=description)\n\n    parser.add_argument(\"model\", help=\"Which model to use for evaluation\")\n    parser.add_argument(\n        \"--classifier\",\n        help=\"Type of the classifier. Only used for component classification.\",\n        choices=[\"default\", \"nn\"],\n        default=\"default\",\n    )\n\n    args = parser.parse_args()\n\n    classify_bugs(args.model, args.classifier)\n", "path": "scripts/bug_classifier.py"}]}