prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Automatic generation of specs.json by running specs.py is broken
  After merging https://github.com/openvinotoolkit/datumaro/pull/1268, `metadata` is newly introduced in `specs.json`, but the automated `specs.json` doesn't create `metadata`, and hence it breaks the lazy_load of importers.
  
  </issue>
  <code>
  [start of src/datumaro/plugins/specs.py]
  1 # Copyright (C) 2023 Intel Corporation
  2 #
  3 # SPDX-License-Identifier: MIT
  4 
  5 from pathlib import Path
  6 
  7 from datumaro.components.lazy_plugin import get_extra_deps, get_lazy_plugin
  8 from datumaro.util import parse_json_file
  9 
  10 _SOURCE_PATH = Path(__file__).resolve()
  11 _SOURCE_DIR = _SOURCE_PATH.parent
  12 _SPECS_JSON_PATH = _SOURCE_DIR / "specs.json"
  13 
  14 
  15 def get_lazy_plugins():
  16     return [
  17         plugin
  18         for plugin in [
  19             get_lazy_plugin(
  20                 spec["import_path"],
  21                 spec["plugin_name"],
  22                 spec["plugin_type"],
  23                 spec.get("extra_deps", []),
  24                 spec.get("metadata", {}),
  25             )
  26             for spec in parse_json_file(str(_SPECS_JSON_PATH))
  27         ]
  28         if plugin is not None
  29     ]
  30 
  31 
  32 if __name__ == "__main__":
  33     from datumaro.components.environment import Environment
  34     from datumaro.util import dump_json_file
  35 
  36     env = Environment(use_lazy_import=False)
  37     plugin_specs = []
  38 
  39     def _enroll_to_plugin_specs(plugins, plugin_type):
  40         global plugin_specs
  41 
  42         for _, plugin in plugins.items():
  43             mod = plugin.__module__
  44             class_name = plugin.__name__
  45             plugin_name = plugin.NAME
  46             plugin_specs += [
  47                 {
  48                     "import_path": f"{mod}.{class_name}",
  49                     "plugin_name": plugin_name,
  50                     "plugin_type": plugin_type,
  51                     "extra_deps": get_extra_deps(plugin),
  52                 }
  53             ]
  54 
  55     _enroll_to_plugin_specs(env.extractors, "DatasetBase")
  56     _enroll_to_plugin_specs(env.importers, "Importer")
  57     _enroll_to_plugin_specs(env.launchers, "Launcher")
  58     _enroll_to_plugin_specs(env.exporters, "Exporter")
  59     _enroll_to_plugin_specs(env.generators, "DatasetGenerator")
  60     _enroll_to_plugin_specs(env.transforms, "Transform")
  61     _enroll_to_plugin_specs(env.validators, "Validator")
  62 
  63     dump_json_file(
  64         _SPECS_JSON_PATH,
  65         sorted(plugin_specs, key=lambda spec: spec["import_path"]),
  66         indent=True,
  67         append_newline=True,
  68     )
  69
  [end of src/datumaro/plugins/specs.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/datumaro/plugins/specs.py b/src/datumaro/plugins/specs.py
  --- a/src/datumaro/plugins/specs.py
  +++ b/src/datumaro/plugins/specs.py
  @@ -43,14 +43,18 @@
               mod = plugin.__module__
               class_name = plugin.__name__
               plugin_name = plugin.NAME
  -            plugin_specs += [
  -                {
  -                    "import_path": f"{mod}.{class_name}",
  -                    "plugin_name": plugin_name,
  -                    "plugin_type": plugin_type,
  -                    "extra_deps": get_extra_deps(plugin),
  -                }
  -            ]
  +            extra_deps = get_extra_deps(plugin)
  +            plugin_spec = {
  +                "import_path": f"{mod}.{class_name}",
  +                "plugin_name": plugin_name,
  +                "plugin_type": plugin_type,
  +            }
  +            if extra_deps:
  +                plugin_spec["extra_deps"] = extra_deps
  +            # Setting metadata for importers
  +            if hasattr(plugin, "get_file_extensions"):
  +                plugin_spec["metadata"] = {"file_extensions": sorted(plugin.get_file_extensions())}
  +            plugin_specs.append(plugin_spec)
   
       _enroll_to_plugin_specs(env.extractors, "DatasetBase")
       _enroll_to_plugin_specs(env.importers, "Importer")
  
verification_info: {"golden_diff": "diff --git a/src/datumaro/plugins/specs.py b/src/datumaro/plugins/specs.py\n--- a/src/datumaro/plugins/specs.py\n+++ b/src/datumaro/plugins/specs.py\n@@ -43,14 +43,18 @@\n             mod = plugin.__module__\n             class_name = plugin.__name__\n             plugin_name = plugin.NAME\n-            plugin_specs += [\n-                {\n-                    \"import_path\": f\"{mod}.{class_name}\",\n-                    \"plugin_name\": plugin_name,\n-                    \"plugin_type\": plugin_type,\n-                    \"extra_deps\": get_extra_deps(plugin),\n-                }\n-            ]\n+            extra_deps = get_extra_deps(plugin)\n+            plugin_spec = {\n+                \"import_path\": f\"{mod}.{class_name}\",\n+                \"plugin_name\": plugin_name,\n+                \"plugin_type\": plugin_type,\n+            }\n+            if extra_deps:\n+                plugin_spec[\"extra_deps\"] = extra_deps\n+            # Setting metadata for importers\n+            if hasattr(plugin, \"get_file_extensions\"):\n+                plugin_spec[\"metadata\"] = {\"file_extensions\": sorted(plugin.get_file_extensions())}\n+            plugin_specs.append(plugin_spec)\n \n     _enroll_to_plugin_specs(env.extractors, \"DatasetBase\")\n     _enroll_to_plugin_specs(env.importers, \"Importer\")\n", "issue": "Automatic generation of specs.json by running specs.py is broken\nAfter merging https://github.com/openvinotoolkit/datumaro/pull/1268, `metadata` is newly introduced in `specs.json`, but the automated `specs.json` doesn't create `metadata`, and hence it breaks the lazy_load of importers.\n", "before_files": [{"content": "# Copyright (C) 2023 Intel Corporation\n#\n# SPDX-License-Identifier: MIT\n\nfrom pathlib import Path\n\nfrom datumaro.components.lazy_plugin import get_extra_deps, get_lazy_plugin\nfrom datumaro.util import parse_json_file\n\n_SOURCE_PATH = Path(__file__).resolve()\n_SOURCE_DIR = _SOURCE_PATH.parent\n_SPECS_JSON_PATH = _SOURCE_DIR / \"specs.json\"\n\n\ndef get_lazy_plugins():\n    return [\n        plugin\n        for plugin in [\n            get_lazy_plugin(\n                spec[\"import_path\"],\n                spec[\"plugin_name\"],\n                spec[\"plugin_type\"],\n                spec.get(\"extra_deps\", []),\n                spec.get(\"metadata\", {}),\n            )\n            for spec in parse_json_file(str(_SPECS_JSON_PATH))\n        ]\n        if plugin is not None\n    ]\n\n\nif __name__ == \"__main__\":\n    from datumaro.components.environment import Environment\n    from datumaro.util import dump_json_file\n\n    env = Environment(use_lazy_import=False)\n    plugin_specs = []\n\n    def _enroll_to_plugin_specs(plugins, plugin_type):\n        global plugin_specs\n\n        for _, plugin in plugins.items():\n            mod = plugin.__module__\n            class_name = plugin.__name__\n            plugin_name = plugin.NAME\n            plugin_specs += [\n                {\n                    \"import_path\": f\"{mod}.{class_name}\",\n                    \"plugin_name\": plugin_name,\n                    \"plugin_type\": plugin_type,\n                    \"extra_deps\": get_extra_deps(plugin),\n                }\n            ]\n\n    _enroll_to_plugin_specs(env.extractors, \"DatasetBase\")\n    _enroll_to_plugin_specs(env.importers, \"Importer\")\n    _enroll_to_plugin_specs(env.launchers, \"Launcher\")\n    _enroll_to_plugin_specs(env.exporters, \"Exporter\")\n    _enroll_to_plugin_specs(env.generators, \"DatasetGenerator\")\n    _enroll_to_plugin_specs(env.transforms, \"Transform\")\n    _enroll_to_plugin_specs(env.validators, \"Validator\")\n\n    dump_json_file(\n        _SPECS_JSON_PATH,\n        sorted(plugin_specs, key=lambda spec: spec[\"import_path\"]),\n        indent=True,\n        append_newline=True,\n    )\n", "path": "src/datumaro/plugins/specs.py"}]}