prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Not all training tasks need commits DB
  Indeed I think none of the ones we currently run as part of the data pipeline need the commits.
  We should:
  - Make the trainer script only download the DBs which are necessary;
  - Remove the dependency on the commit retrieval task in the data-pipeline.yml.
  
  </issue>
  <code>
  [start of scripts/trainer.py]
  1 # -*- coding: utf-8 -*-
  2 
  3 import argparse
  4 import lzma
  5 import os
  6 import shutil
  7 from logging import INFO, basicConfig, getLogger
  8 from urllib.request import urlretrieve
  9 
  10 from bugbug.models.component import ComponentModel
  11 from bugbug.models.defect_enhancement_task import DefectEnhancementTaskModel
  12 from bugbug.models.regression import RegressionModel
  13 from bugbug.models.tracking import TrackingModel
  14 
  15 basicConfig(level=INFO)
  16 logger = getLogger(__name__)
  17 
  18 BASE_URL = "https://index.taskcluster.net/v1/task/project.relman.bugbug.data_{}.latest/artifacts/public"
  19 
  20 
  21 class Trainer(object):
  22     def decompress_file(self, path):
  23         with lzma.open(f"{path}.xz", "rb") as input_f:
  24             with open(path, "wb") as output_f:
  25                 shutil.copyfileobj(input_f, output_f)
  26 
  27     def compress_file(self, path):
  28         with open(path, "rb") as input_f:
  29             with lzma.open(f"{path}.xz", "wb") as output_f:
  30                 shutil.copyfileobj(input_f, output_f)
  31 
  32     def train_defect_enhancement_task(self):
  33         logger.info("Training *defect vs enhancement vs task* model")
  34         model = DefectEnhancementTaskModel()
  35         model.train()
  36         self.compress_file("defectenhancementtaskmodel")
  37 
  38     def train_component(self):
  39         logger.info("Training *component* model")
  40         model = ComponentModel()
  41         model.train()
  42         self.compress_file("componentmodel")
  43 
  44     def train_regression(self):
  45         logger.info("Training *regression vs non-regression* model")
  46         model = RegressionModel()
  47         model.train()
  48         self.compress_file("regressionmodel")
  49 
  50     def train_tracking(self):
  51         logger.info("Training *tracking* model")
  52         model = TrackingModel()
  53         model.train()
  54         self.compress_file("trackingmodel")
  55 
  56     def go(self, model):
  57         # TODO: Stop hard-coding them
  58         valid_models = ["defect", "component", "regression", "tracking"]
  59 
  60         if model not in valid_models:
  61             exception = (
  62                 f"Invalid model {model!r} name, use one of {valid_models!r} instead"
  63             )
  64             raise ValueError(exception)
  65 
  66         # Download datasets that were built by bugbug_data.
  67         os.makedirs("data", exist_ok=True)
  68 
  69         # Bugs.json
  70         logger.info("Downloading bugs database")
  71         bugs_url = BASE_URL.format("bugs")
  72         urlretrieve(f"{bugs_url}/bugs.json.xz", "data/bugs.json.xz")
  73         logger.info("Decompressing bugs database")
  74         self.decompress_file("data/bugs.json")
  75 
  76         # Commits.json
  77         logger.info("Downloading commits database")
  78         commits_url = BASE_URL.format("commits")
  79         urlretrieve(f"{commits_url}/commits.json.xz", "data/commits.json.xz")
  80         logger.info("Decompressing commits database")
  81         self.decompress_file("data/commits.json")
  82 
  83         if model == "defect":
  84             # Train classifier for defect-vs-enhancement-vs-task.
  85             self.train_defect_enhancement_task()
  86         elif model == "component":
  87             # Train classifier for the component of a bug.
  88             self.train_component()
  89         elif model == "regression":
  90             # Train classifier for regression-vs-nonregression.
  91             self.train_regression()
  92         elif model == "tracking":
  93             # Train classifier for tracking bugs.
  94             self.train_tracking()
  95         else:
  96             # We shouldn't be here
  97             raise Exception("valid_models is likely not up-to-date anymore")
  98 
  99 
  100 def main():
  101     description = "Train the models"
  102     parser = argparse.ArgumentParser(description=description)
  103 
  104     parser.add_argument("model", help="Which model to train.")
  105 
  106     args = parser.parse_args()
  107 
  108     retriever = Trainer()
  109     retriever.go(args.model)
  110
  [end of scripts/trainer.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/trainer.py b/scripts/trainer.py
  --- a/scripts/trainer.py
  +++ b/scripts/trainer.py
  @@ -73,13 +73,6 @@
           logger.info("Decompressing bugs database")
           self.decompress_file("data/bugs.json")
   
  -        # Commits.json
  -        logger.info("Downloading commits database")
  -        commits_url = BASE_URL.format("commits")
  -        urlretrieve(f"{commits_url}/commits.json.xz", "data/commits.json.xz")
  -        logger.info("Decompressing commits database")
  -        self.decompress_file("data/commits.json")
  -
           if model == "defect":
               # Train classifier for defect-vs-enhancement-vs-task.
               self.train_defect_enhancement_task()
  
verification_info: {"golden_diff": "diff --git a/scripts/trainer.py b/scripts/trainer.py\n--- a/scripts/trainer.py\n+++ b/scripts/trainer.py\n@@ -73,13 +73,6 @@\n         logger.info(\"Decompressing bugs database\")\n         self.decompress_file(\"data/bugs.json\")\n \n-        # Commits.json\n-        logger.info(\"Downloading commits database\")\n-        commits_url = BASE_URL.format(\"commits\")\n-        urlretrieve(f\"{commits_url}/commits.json.xz\", \"data/commits.json.xz\")\n-        logger.info(\"Decompressing commits database\")\n-        self.decompress_file(\"data/commits.json\")\n-\n         if model == \"defect\":\n             # Train classifier for defect-vs-enhancement-vs-task.\n             self.train_defect_enhancement_task()\n", "issue": "Not all training tasks need commits DB\nIndeed I think none of the ones we currently run as part of the data pipeline need the commits.\r\nWe should:\r\n- Make the trainer script only download the DBs which are necessary;\r\n- Remove the dependency on the commit retrieval task in the data-pipeline.yml.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\nimport argparse\nimport lzma\nimport os\nimport shutil\nfrom logging import INFO, basicConfig, getLogger\nfrom urllib.request import urlretrieve\n\nfrom bugbug.models.component import ComponentModel\nfrom bugbug.models.defect_enhancement_task import DefectEnhancementTaskModel\nfrom bugbug.models.regression import RegressionModel\nfrom bugbug.models.tracking import TrackingModel\n\nbasicConfig(level=INFO)\nlogger = getLogger(__name__)\n\nBASE_URL = \"https://index.taskcluster.net/v1/task/project.relman.bugbug.data_{}.latest/artifacts/public\"\n\n\nclass Trainer(object):\n    def decompress_file(self, path):\n        with lzma.open(f\"{path}.xz\", \"rb\") as input_f:\n            with open(path, \"wb\") as output_f:\n                shutil.copyfileobj(input_f, output_f)\n\n    def compress_file(self, path):\n        with open(path, \"rb\") as input_f:\n            with lzma.open(f\"{path}.xz\", \"wb\") as output_f:\n                shutil.copyfileobj(input_f, output_f)\n\n    def train_defect_enhancement_task(self):\n        logger.info(\"Training *defect vs enhancement vs task* model\")\n        model = DefectEnhancementTaskModel()\n        model.train()\n        self.compress_file(\"defectenhancementtaskmodel\")\n\n    def train_component(self):\n        logger.info(\"Training *component* model\")\n        model = ComponentModel()\n        model.train()\n        self.compress_file(\"componentmodel\")\n\n    def train_regression(self):\n        logger.info(\"Training *regression vs non-regression* model\")\n        model = RegressionModel()\n        model.train()\n        self.compress_file(\"regressionmodel\")\n\n    def train_tracking(self):\n        logger.info(\"Training *tracking* model\")\n        model = TrackingModel()\n        model.train()\n        self.compress_file(\"trackingmodel\")\n\n    def go(self, model):\n        # TODO: Stop hard-coding them\n        valid_models = [\"defect\", \"component\", \"regression\", \"tracking\"]\n\n        if model not in valid_models:\n            exception = (\n                f\"Invalid model {model!r} name, use one of {valid_models!r} instead\"\n            )\n            raise ValueError(exception)\n\n        # Download datasets that were built by bugbug_data.\n        os.makedirs(\"data\", exist_ok=True)\n\n        # Bugs.json\n        logger.info(\"Downloading bugs database\")\n        bugs_url = BASE_URL.format(\"bugs\")\n        urlretrieve(f\"{bugs_url}/bugs.json.xz\", \"data/bugs.json.xz\")\n        logger.info(\"Decompressing bugs database\")\n        self.decompress_file(\"data/bugs.json\")\n\n        # Commits.json\n        logger.info(\"Downloading commits database\")\n        commits_url = BASE_URL.format(\"commits\")\n        urlretrieve(f\"{commits_url}/commits.json.xz\", \"data/commits.json.xz\")\n        logger.info(\"Decompressing commits database\")\n        self.decompress_file(\"data/commits.json\")\n\n        if model == \"defect\":\n            # Train classifier for defect-vs-enhancement-vs-task.\n            self.train_defect_enhancement_task()\n        elif model == \"component\":\n            # Train classifier for the component of a bug.\n            self.train_component()\n        elif model == \"regression\":\n            # Train classifier for regression-vs-nonregression.\n            self.train_regression()\n        elif model == \"tracking\":\n            # Train classifier for tracking bugs.\n            self.train_tracking()\n        else:\n            # We shouldn't be here\n            raise Exception(\"valid_models is likely not up-to-date anymore\")\n\n\ndef main():\n    description = \"Train the models\"\n    parser = argparse.ArgumentParser(description=description)\n\n    parser.add_argument(\"model\", help=\"Which model to train.\")\n\n    args = parser.parse_args()\n\n    retriever = Trainer()\n    retriever.go(args.model)\n", "path": "scripts/trainer.py"}]}