prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Revert component-based scripts lookup
  ### Is your feature request related to a problem? Please describe
  
  In https://github.com/opensearch-project/opensearch-build/pull/2934 we have added a way to include component build scripts. There are several problems with that.
  
  1. In https://github.com/opensearch-project/opensearch-build/issues/2188 we agreed to split monorepos. The maps monorepo came in as another new kind of monorepo that should not be supported. 
  2. There are no tests in the PR.
  3. The new feature of path lookup is not documented in https://github.com/opensearch-project/opensearch-build/blob/cbe6841a3c459b65d5fb17b713994e5c01d7ee8e/src/paths/script_finder.py#L27
  
  ### Describe the solution you'd like
  
  1. Add tests and documentation on top of https://github.com/opensearch-project/opensearch-build/pull/2934.
  1. Split the maps monorepo, https://github.com/opensearch-project/opensearch-build/issues/2188
  1. Revert https://github.com/opensearch-project/opensearch-build/pull/2934
  
  
  
  ### Describe alternatives you've considered
  
  _No response_
  
  ### Additional context
  
  _No response_
  
  </issue>
  <code>
  [start of src/paths/script_finder.py]
  1 # Copyright OpenSearch Contributors
  2 # SPDX-License-Identifier: Apache-2.0
  3 #
  4 # The OpenSearch Contributors require contributions made to
  5 # this file be licensed under the Apache-2.0 license or a
  6 # compatible open source license.
  7 
  8 import os
  9 from typing import Callable, List
  10 
  11 
  12 class ScriptFinder:
  13     class ScriptNotFoundError(Exception):
  14         def __init__(self, kind: str, paths: List[str]) -> None:
  15             self.kind = kind
  16             self.paths = paths
  17             super().__init__(f"Could not find {kind} script. Looked in {paths}.")
  18 
  19     component_scripts_path = os.path.realpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.path.join("..", "..", "scripts", "components")))
  20 
  21     default_scripts_path = os.path.realpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.path.join("..", "..", "scripts", "default")))
  22 
  23     """
  24     ScriptFinder is a helper that abstracts away the details of where to look for build, test and install scripts.
  25 
  26     For build.sh and integtest.sh scripts, given a component name and a checked-out Git repository,
  27     it will look in the following locations, in order:
  28       * <component_scripts_path>/<component_name>/<script-name>
  29       * /<component_name>/<script-name> in the component's Git repository
  30       * root of the component's Git repository
  31       * /scripts/<script-name> in the component's Git repository
  32       * <default_scripts_path>/<script-name>
  33 
  34     For install.sh scripts, given a component name, it will look in the following locations, in order:
  35       * <component_scripts_path>/<component_name>/<script-name>
  36       * <default_scripts_path>/<script-name>
  37     """
  38 
  39     @classmethod
  40     def __find_script(cls, name: str, paths: List[str]) -> str:
  41         exists: Callable[[str], bool] = lambda path: os.path.exists(path)
  42         script = next(filter(exists, paths), None)
  43         if script is None:
  44             raise ScriptFinder.ScriptNotFoundError(name, paths)
  45 
  46         return script
  47 
  48     @classmethod
  49     def __find_named_script(cls, script_name: str, component_name: str, git_dir: str) -> str:
  50         paths = [
  51             os.path.realpath(os.path.join(cls.component_scripts_path, component_name, script_name)),
  52             os.path.realpath(os.path.join(git_dir, component_name, script_name)),
  53             os.path.realpath(os.path.join(git_dir, script_name)),
  54             os.path.realpath(os.path.join(git_dir, "scripts", script_name)),
  55             os.path.realpath(os.path.join(cls.default_scripts_path, script_name)),
  56         ]
  57 
  58         return cls.__find_script(script_name, paths)
  59 
  60     @classmethod
  61     def find_build_script(cls, project: str, component_name: str, git_dir: str) -> str:
  62         paths = [
  63             os.path.realpath(os.path.join(cls.component_scripts_path, component_name, "build.sh")),
  64             os.path.realpath(os.path.join(git_dir, component_name, "build.sh")),
  65             os.path.realpath(os.path.join(git_dir, "build.sh")),
  66             os.path.realpath(os.path.join(git_dir, "scripts", "build.sh")),
  67             os.path.realpath(
  68                 os.path.join(
  69                     cls.default_scripts_path,
  70                     project.replace(" ", "-").lower(),
  71                     "build.sh",
  72                 )
  73             ),
  74         ]
  75 
  76         return cls.__find_script("build.sh", paths)
  77 
  78     @classmethod
  79     def find_install_script(cls, component_name: str) -> str:
  80         paths = [
  81             os.path.realpath(os.path.join(cls.component_scripts_path, component_name, "install.sh")),
  82             os.path.realpath(os.path.join(cls.default_scripts_path, "install.sh")),
  83         ]
  84 
  85         return cls.__find_script("install.sh", paths)
  86 
  87     @classmethod
  88     def find_integ_test_script(cls, component_name: str, git_dir: str) -> str:
  89         return cls.__find_named_script("integtest.sh", component_name, git_dir)
  90 
  91     @classmethod
  92     def find_bwc_test_script(cls, component_name: str, git_dir: str) -> str:
  93         script_name = "bwctest.sh"
  94         paths = [
  95             os.path.realpath(os.path.join(cls.default_scripts_path, script_name)),
  96             os.path.realpath(os.path.join(cls.component_scripts_path, component_name, script_name)),
  97             os.path.realpath(os.path.join(git_dir, component_name, script_name)),
  98             os.path.realpath(os.path.join(git_dir, script_name)),
  99             os.path.realpath(os.path.join(git_dir, "scripts", script_name)),
  100         ]
  101 
  102         return cls.__find_script(script_name, paths)
  103
  [end of src/paths/script_finder.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/src/paths/script_finder.py b/src/paths/script_finder.py
  --- a/src/paths/script_finder.py
  +++ b/src/paths/script_finder.py
  @@ -26,7 +26,6 @@
       For build.sh and integtest.sh scripts, given a component name and a checked-out Git repository,
       it will look in the following locations, in order:
         * <component_scripts_path>/<component_name>/<script-name>
  -      * /<component_name>/<script-name> in the component's Git repository
         * root of the component's Git repository
         * /scripts/<script-name> in the component's Git repository
         * <default_scripts_path>/<script-name>
  @@ -49,7 +48,6 @@
       def __find_named_script(cls, script_name: str, component_name: str, git_dir: str) -> str:
           paths = [
               os.path.realpath(os.path.join(cls.component_scripts_path, component_name, script_name)),
  -            os.path.realpath(os.path.join(git_dir, component_name, script_name)),
               os.path.realpath(os.path.join(git_dir, script_name)),
               os.path.realpath(os.path.join(git_dir, "scripts", script_name)),
               os.path.realpath(os.path.join(cls.default_scripts_path, script_name)),
  @@ -61,7 +59,6 @@
       def find_build_script(cls, project: str, component_name: str, git_dir: str) -> str:
           paths = [
               os.path.realpath(os.path.join(cls.component_scripts_path, component_name, "build.sh")),
  -            os.path.realpath(os.path.join(git_dir, component_name, "build.sh")),
               os.path.realpath(os.path.join(git_dir, "build.sh")),
               os.path.realpath(os.path.join(git_dir, "scripts", "build.sh")),
               os.path.realpath(
  
verification_info: {"golden_diff": "diff --git a/src/paths/script_finder.py b/src/paths/script_finder.py\n--- a/src/paths/script_finder.py\n+++ b/src/paths/script_finder.py\n@@ -26,7 +26,6 @@\n     For build.sh and integtest.sh scripts, given a component name and a checked-out Git repository,\n     it will look in the following locations, in order:\n       * <component_scripts_path>/<component_name>/<script-name>\n-      * /<component_name>/<script-name> in the component's Git repository\n       * root of the component's Git repository\n       * /scripts/<script-name> in the component's Git repository\n       * <default_scripts_path>/<script-name>\n@@ -49,7 +48,6 @@\n     def __find_named_script(cls, script_name: str, component_name: str, git_dir: str) -> str:\n         paths = [\n             os.path.realpath(os.path.join(cls.component_scripts_path, component_name, script_name)),\n-            os.path.realpath(os.path.join(git_dir, component_name, script_name)),\n             os.path.realpath(os.path.join(git_dir, script_name)),\n             os.path.realpath(os.path.join(git_dir, \"scripts\", script_name)),\n             os.path.realpath(os.path.join(cls.default_scripts_path, script_name)),\n@@ -61,7 +59,6 @@\n     def find_build_script(cls, project: str, component_name: str, git_dir: str) -> str:\n         paths = [\n             os.path.realpath(os.path.join(cls.component_scripts_path, component_name, \"build.sh\")),\n-            os.path.realpath(os.path.join(git_dir, component_name, \"build.sh\")),\n             os.path.realpath(os.path.join(git_dir, \"build.sh\")),\n             os.path.realpath(os.path.join(git_dir, \"scripts\", \"build.sh\")),\n             os.path.realpath(\n", "issue": "Revert component-based scripts lookup\n### Is your feature request related to a problem? Please describe\n\nIn https://github.com/opensearch-project/opensearch-build/pull/2934 we have added a way to include component build scripts. There are several problems with that.\r\n\r\n1. In https://github.com/opensearch-project/opensearch-build/issues/2188 we agreed to split monorepos. The maps monorepo came in as another new kind of monorepo that should not be supported. \r\n2. There are no tests in the PR.\r\n3. The new feature of path lookup is not documented in https://github.com/opensearch-project/opensearch-build/blob/cbe6841a3c459b65d5fb17b713994e5c01d7ee8e/src/paths/script_finder.py#L27\n\n### Describe the solution you'd like\n\n1. Add tests and documentation on top of https://github.com/opensearch-project/opensearch-build/pull/2934.\r\n1. Split the maps monorepo, https://github.com/opensearch-project/opensearch-build/issues/2188\r\n1. Revert https://github.com/opensearch-project/opensearch-build/pull/2934\r\n\r\n\n\n### Describe alternatives you've considered\n\n_No response_\n\n### Additional context\n\n_No response_\n", "before_files": [{"content": "# Copyright OpenSearch Contributors\n# SPDX-License-Identifier: Apache-2.0\n#\n# The OpenSearch Contributors require contributions made to\n# this file be licensed under the Apache-2.0 license or a\n# compatible open source license.\n\nimport os\nfrom typing import Callable, List\n\n\nclass ScriptFinder:\n    class ScriptNotFoundError(Exception):\n        def __init__(self, kind: str, paths: List[str]) -> None:\n            self.kind = kind\n            self.paths = paths\n            super().__init__(f\"Could not find {kind} script. Looked in {paths}.\")\n\n    component_scripts_path = os.path.realpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.path.join(\"..\", \"..\", \"scripts\", \"components\")))\n\n    default_scripts_path = os.path.realpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.path.join(\"..\", \"..\", \"scripts\", \"default\")))\n\n    \"\"\"\n    ScriptFinder is a helper that abstracts away the details of where to look for build, test and install scripts.\n\n    For build.sh and integtest.sh scripts, given a component name and a checked-out Git repository,\n    it will look in the following locations, in order:\n      * <component_scripts_path>/<component_name>/<script-name>\n      * /<component_name>/<script-name> in the component's Git repository\n      * root of the component's Git repository\n      * /scripts/<script-name> in the component's Git repository\n      * <default_scripts_path>/<script-name>\n\n    For install.sh scripts, given a component name, it will look in the following locations, in order:\n      * <component_scripts_path>/<component_name>/<script-name>\n      * <default_scripts_path>/<script-name>\n    \"\"\"\n\n    @classmethod\n    def __find_script(cls, name: str, paths: List[str]) -> str:\n        exists: Callable[[str], bool] = lambda path: os.path.exists(path)\n        script = next(filter(exists, paths), None)\n        if script is None:\n            raise ScriptFinder.ScriptNotFoundError(name, paths)\n\n        return script\n\n    @classmethod\n    def __find_named_script(cls, script_name: str, component_name: str, git_dir: str) -> str:\n        paths = [\n            os.path.realpath(os.path.join(cls.component_scripts_path, component_name, script_name)),\n            os.path.realpath(os.path.join(git_dir, component_name, script_name)),\n            os.path.realpath(os.path.join(git_dir, script_name)),\n            os.path.realpath(os.path.join(git_dir, \"scripts\", script_name)),\n            os.path.realpath(os.path.join(cls.default_scripts_path, script_name)),\n        ]\n\n        return cls.__find_script(script_name, paths)\n\n    @classmethod\n    def find_build_script(cls, project: str, component_name: str, git_dir: str) -> str:\n        paths = [\n            os.path.realpath(os.path.join(cls.component_scripts_path, component_name, \"build.sh\")),\n            os.path.realpath(os.path.join(git_dir, component_name, \"build.sh\")),\n            os.path.realpath(os.path.join(git_dir, \"build.sh\")),\n            os.path.realpath(os.path.join(git_dir, \"scripts\", \"build.sh\")),\n            os.path.realpath(\n                os.path.join(\n                    cls.default_scripts_path,\n                    project.replace(\" \", \"-\").lower(),\n                    \"build.sh\",\n                )\n            ),\n        ]\n\n        return cls.__find_script(\"build.sh\", paths)\n\n    @classmethod\n    def find_install_script(cls, component_name: str) -> str:\n        paths = [\n            os.path.realpath(os.path.join(cls.component_scripts_path, component_name, \"install.sh\")),\n            os.path.realpath(os.path.join(cls.default_scripts_path, \"install.sh\")),\n        ]\n\n        return cls.__find_script(\"install.sh\", paths)\n\n    @classmethod\n    def find_integ_test_script(cls, component_name: str, git_dir: str) -> str:\n        return cls.__find_named_script(\"integtest.sh\", component_name, git_dir)\n\n    @classmethod\n    def find_bwc_test_script(cls, component_name: str, git_dir: str) -> str:\n        script_name = \"bwctest.sh\"\n        paths = [\n            os.path.realpath(os.path.join(cls.default_scripts_path, script_name)),\n            os.path.realpath(os.path.join(cls.component_scripts_path, component_name, script_name)),\n            os.path.realpath(os.path.join(git_dir, component_name, script_name)),\n            os.path.realpath(os.path.join(git_dir, script_name)),\n            os.path.realpath(os.path.join(git_dir, \"scripts\", script_name)),\n        ]\n\n        return cls.__find_script(script_name, paths)\n", "path": "src/paths/script_finder.py"}]}