We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/datumaro/plugins/specs.py`
Content:
```
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 FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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")

{"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"}], "after_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            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    _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"}]}