We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
elementClass is missing in datasource-properties.json when no mag1 resolution is available


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `wkcuber/metadata.py`
Content:
```
1 import json
2 import re
3 import wkw
4 import logging
5 import numpy as np
6 
7 from argparse import ArgumentParser
8 from glob import iglob
9 from os import path, listdir
10 from typing import Optional
11 from .mag import Mag
12 from typing import List
13 
14 
15 def create_parser():
16     parser = ArgumentParser()
17 
18     parser.add_argument("path", help="Directory containing the dataset.")
19 
20     parser.add_argument("--name", "-n", help="Name of the dataset")
21 
22     parser.add_argument(
23         "--scale",
24         "-s",
25         help="Scale of the dataset (e.g. 11.2,11.2,25)",
26         default="1,1,1",
27     )
28 
29     group = parser.add_mutually_exclusive_group()
30     group.add_argument(
31         "--compute_max_id",
32         "-c",
33         help="set to compute max id",
34         default=False,
35         action="store_true",
36     )
37     group.add_argument("--max_id", help="set max id of segmentation.", default=0)
38 
39     return parser
40 
41 
42 def write_webknossos_metadata(
43     dataset_path,
44     name,
45     scale,
46     max_id=0,
47     compute_max_id=False,
48     exact_bounding_box: Optional[dict] = None,
49 ):
50 
51     # Generate a metadata file for webKnossos
52     # Currently includes no source of information for team
53     datasource_properties_path = path.join(dataset_path, "datasource-properties.json")
54     layers = list(
55         detect_layers(dataset_path, max_id, compute_max_id, exact_bounding_box)
56     )
57     with open(datasource_properties_path, "wt") as datasource_properties_json:
58         json.dump(
59             {
60                 "id": {"name": name, "team": "<unknown>"},
61                 "dataLayers": layers,
62                 "scale": scale,
63             },
64             datasource_properties_json,
65             indent=2,
66         )
67 
68 
69 def read_metadata_for_layer(wkw_path, layer_name):
70     datasource_properties = json.load(
71         open(path.join(wkw_path, "datasource-properties.json"), "r")
72     )
73     layers = datasource_properties["dataLayers"]
74     layer_info = next(layer for layer in layers if layer["name"] == layer_name)
75     dtype = np.dtype(layer_info["elementClass"])
76     bounding_box = layer_info["boundingBox"]
77     origin = bounding_box["topLeft"]
78     bounding_box = [
79         bounding_box["width"],
80         bounding_box["height"],
81         bounding_box["depth"],
82     ]
83 
84     return layer_info, dtype, bounding_box, origin
85 
86 
87 def detect_dtype(dataset_path, layer, mag: Mag = Mag(1)):
88     layer_path = path.join(dataset_path, layer, str(mag))
89     if path.exists(layer_path):
90         with wkw.Dataset.open(layer_path) as dataset:
91             voxel_type = dataset.header.voxel_type
92             num_channels = dataset.header.num_channels
93             voxel_size = np.dtype(voxel_type)
94             if voxel_size == np.uint8 and num_channels > 1:
95                 return "uint" + str(8 * num_channels)
96             else:
97                 return str(np.dtype(voxel_type))
98 
99 
100 def detect_cubeLength(dataset_path, layer, mag: Mag = Mag(1)):
101     layer_path = path.join(dataset_path, layer, str(mag))
102     if path.exists(layer_path):
103         with wkw.Dataset.open(layer_path) as dataset:
104             return dataset.header.block_len * dataset.header.file_len
105 
106 
107 def detect_bbox(dataset_path, layer, mag: Mag = Mag(1)):
108     # Detect the coarse bounding box of a dataset by iterating
109     # over the WKW cubes
110     layer_path = path.join(dataset_path, layer, str(mag))
111 
112     def list_files(layer_path):
113         return iglob(path.join(layer_path, "*", "*", "*.wkw"), recursive=True)
114 
115     def parse_cube_file_name(filename):
116         CUBE_REGEX = re.compile(r"z(\d+)/y(\d+)/x(\d+)(\.wkw)$")
117         m = CUBE_REGEX.search(filename)
118         return (int(m.group(3)), int(m.group(2)), int(m.group(1)))
119 
120     def list_cubes(layer_path):
121         return (parse_cube_file_name(f) for f in list_files(layer_path))
122 
123     xs, ys, zs = list(zip(*list_cubes(layer_path)))
124 
125     min_x, min_y, min_z = min(xs), min(ys), min(zs)
126     max_x, max_y, max_z = max(xs), max(ys), max(zs)
127 
128     cubeLength = detect_cubeLength(dataset_path, layer, mag)
129 
130     return {
131         "topLeft": [min_x * cubeLength, min_y * cubeLength, min_z * cubeLength],
132         "width": (1 + max_x - min_x) * cubeLength,
133         "height": (1 + max_y - min_y) * cubeLength,
134         "depth": (1 + max_z - min_z) * cubeLength,
135     }
136 
137 
138 def detect_resolutions(dataset_path, layer) -> List[Mag]:
139     for mag in listdir(path.join(dataset_path, layer)):
140         try:
141             yield Mag(mag)
142         except ValueError:
143             logging.info("ignoring {} as resolution".format(mag))
144 
145 
146 def detect_standard_layer(dataset_path, layer_name, exact_bounding_box=None):
147     # Perform metadata detection for well-known layers
148 
149     if exact_bounding_box is None:
150         bbox = detect_bbox(dataset_path, layer_name)
151     else:
152         bbox = exact_bounding_box
153 
154     dtype = detect_dtype(dataset_path, layer_name)
155 
156     mags = list(detect_resolutions(dataset_path, layer_name))
157     mags = sorted(mags)
158     resolutions = [
159         {
160             "resolution": mag.to_array(),
161             "cubeLength": detect_cubeLength(dataset_path, layer_name, mag),
162         }
163         for mag in mags
164     ]
165 
166     return {
167         "dataFormat": "wkw",
168         "name": layer_name,
169         "category": layer_name,
170         "elementClass": dtype,
171         "boundingBox": bbox,
172         "wkwResolutions": list(resolutions),
173     }
174 
175 
176 def detect_segmentation_layer(
177     dataset_path, layer_name, max_id, compute_max_id=False, exact_bounding_box=None
178 ):
179     layer_info = detect_standard_layer(dataset_path, layer_name, exact_bounding_box)
180     layer_info["mappings"] = []
181     layer_info["largestSegmentId"] = max_id
182 
183     if compute_max_id:
184         logging.info("Computing max id of layer={}".format(layer_name))
185         # Computing the current largest segment id
186         # This may take very long due to IO load
187         layer_path = path.join(dataset_path, layer_name, "1")
188         with wkw.Dataset.open(layer_path) as dataset:
189             bbox = layer_info["boundingBox"]
190             layer_info["largestSegmentId"] = int(
191                 np.max(
192                     dataset.read(
193                         bbox["topLeft"], [bbox["width"], bbox["height"], bbox["depth"]]
194                     )
195                 )
196             )
197             logging.info(
198                 "Max id of layer={} is {}".format(
199                     layer_name, layer_info["largestSegmentId"]
200                 )
201             )
202 
203     return layer_info
204 
205 
206 def detect_layers(dataset_path, max_id, compute_max_id, exact_bounding_box=None):
207     # Detect metadata for well-known layers, e.g. color and segmentation
208     if path.exists(path.join(dataset_path, "color")):
209         yield detect_standard_layer(dataset_path, "color", exact_bounding_box)
210     if path.exists(path.join(dataset_path, "segmentation")):
211         yield detect_segmentation_layer(
212             dataset_path, "segmentation", max_id, compute_max_id, exact_bounding_box
213         )
214 
215 
216 if __name__ == "__main__":
217     logging.basicConfig(level=logging.DEBUG)
218     args = create_parser().parse_args()
219     scale = tuple(float(x) for x in args.scale.split(","))
220     write_webknossos_metadata(
221         args.path, args.name, scale, args.max_id, args.compute_max_id
222     )
223
```
--- 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/wkcuber/metadata.py b/wkcuber/metadata.py
--- a/wkcuber/metadata.py
+++ b/wkcuber/metadata.py
@@ -151,8 +151,6 @@
     else:
         bbox = exact_bounding_box
 
-    dtype = detect_dtype(dataset_path, layer_name)
-
     mags = list(detect_resolutions(dataset_path, layer_name))
     mags = sorted(mags)
     resolutions = [
@@ -163,6 +161,9 @@
         for mag in mags
     ]
 
+    assert len(mags) > 0, "No resolutions found"
+    dtype = detect_dtype(dataset_path, layer_name, mags[0])
+
     return {
         "dataFormat": "wkw",
         "name": layer_name,

{"golden_diff": "diff --git a/wkcuber/metadata.py b/wkcuber/metadata.py\n--- a/wkcuber/metadata.py\n+++ b/wkcuber/metadata.py\n@@ -151,8 +151,6 @@\n     else:\n         bbox = exact_bounding_box\n \n-    dtype = detect_dtype(dataset_path, layer_name)\n-\n     mags = list(detect_resolutions(dataset_path, layer_name))\n     mags = sorted(mags)\n     resolutions = [\n@@ -163,6 +161,9 @@\n         for mag in mags\n     ]\n \n+    assert len(mags) > 0, \"No resolutions found\"\n+    dtype = detect_dtype(dataset_path, layer_name, mags[0])\n+\n     return {\n         \"dataFormat\": \"wkw\",\n         \"name\": layer_name,\n", "issue": "elementClass is missing in datasource-properties.json when no mag1 resolution is available\n\n", "before_files": [{"content": "import json\nimport re\nimport wkw\nimport logging\nimport numpy as np\n\nfrom argparse import ArgumentParser\nfrom glob import iglob\nfrom os import path, listdir\nfrom typing import Optional\nfrom .mag import Mag\nfrom typing import List\n\n\ndef create_parser():\n    parser = ArgumentParser()\n\n    parser.add_argument(\"path\", help=\"Directory containing the dataset.\")\n\n    parser.add_argument(\"--name\", \"-n\", help=\"Name of the dataset\")\n\n    parser.add_argument(\n        \"--scale\",\n        \"-s\",\n        help=\"Scale of the dataset (e.g. 11.2,11.2,25)\",\n        default=\"1,1,1\",\n    )\n\n    group = parser.add_mutually_exclusive_group()\n    group.add_argument(\n        \"--compute_max_id\",\n        \"-c\",\n        help=\"set to compute max id\",\n        default=False,\n        action=\"store_true\",\n    )\n    group.add_argument(\"--max_id\", help=\"set max id of segmentation.\", default=0)\n\n    return parser\n\n\ndef write_webknossos_metadata(\n    dataset_path,\n    name,\n    scale,\n    max_id=0,\n    compute_max_id=False,\n    exact_bounding_box: Optional[dict] = None,\n):\n\n    # Generate a metadata file for webKnossos\n    # Currently includes no source of information for team\n    datasource_properties_path = path.join(dataset_path, \"datasource-properties.json\")\n    layers = list(\n        detect_layers(dataset_path, max_id, compute_max_id, exact_bounding_box)\n    )\n    with open(datasource_properties_path, \"wt\") as datasource_properties_json:\n        json.dump(\n            {\n                \"id\": {\"name\": name, \"team\": \"<unknown>\"},\n                \"dataLayers\": layers,\n                \"scale\": scale,\n            },\n            datasource_properties_json,\n            indent=2,\n        )\n\n\ndef read_metadata_for_layer(wkw_path, layer_name):\n    datasource_properties = json.load(\n        open(path.join(wkw_path, \"datasource-properties.json\"), \"r\")\n    )\n    layers = datasource_properties[\"dataLayers\"]\n    layer_info = next(layer for layer in layers if layer[\"name\"] == layer_name)\n    dtype = np.dtype(layer_info[\"elementClass\"])\n    bounding_box = layer_info[\"boundingBox\"]\n    origin = bounding_box[\"topLeft\"]\n    bounding_box = [\n        bounding_box[\"width\"],\n        bounding_box[\"height\"],\n        bounding_box[\"depth\"],\n    ]\n\n    return layer_info, dtype, bounding_box, origin\n\n\ndef detect_dtype(dataset_path, layer, mag: Mag = Mag(1)):\n    layer_path = path.join(dataset_path, layer, str(mag))\n    if path.exists(layer_path):\n        with wkw.Dataset.open(layer_path) as dataset:\n            voxel_type = dataset.header.voxel_type\n            num_channels = dataset.header.num_channels\n            voxel_size = np.dtype(voxel_type)\n            if voxel_size == np.uint8 and num_channels > 1:\n                return \"uint\" + str(8 * num_channels)\n            else:\n                return str(np.dtype(voxel_type))\n\n\ndef detect_cubeLength(dataset_path, layer, mag: Mag = Mag(1)):\n    layer_path = path.join(dataset_path, layer, str(mag))\n    if path.exists(layer_path):\n        with wkw.Dataset.open(layer_path) as dataset:\n            return dataset.header.block_len * dataset.header.file_len\n\n\ndef detect_bbox(dataset_path, layer, mag: Mag = Mag(1)):\n    # Detect the coarse bounding box of a dataset by iterating\n    # over the WKW cubes\n    layer_path = path.join(dataset_path, layer, str(mag))\n\n    def list_files(layer_path):\n        return iglob(path.join(layer_path, \"*\", \"*\", \"*.wkw\"), recursive=True)\n\n    def parse_cube_file_name(filename):\n        CUBE_REGEX = re.compile(r\"z(\\d+)/y(\\d+)/x(\\d+)(\\.wkw)$\")\n        m = CUBE_REGEX.search(filename)\n        return (int(m.group(3)), int(m.group(2)), int(m.group(1)))\n\n    def list_cubes(layer_path):\n        return (parse_cube_file_name(f) for f in list_files(layer_path))\n\n    xs, ys, zs = list(zip(*list_cubes(layer_path)))\n\n    min_x, min_y, min_z = min(xs), min(ys), min(zs)\n    max_x, max_y, max_z = max(xs), max(ys), max(zs)\n\n    cubeLength = detect_cubeLength(dataset_path, layer, mag)\n\n    return {\n        \"topLeft\": [min_x * cubeLength, min_y * cubeLength, min_z * cubeLength],\n        \"width\": (1 + max_x - min_x) * cubeLength,\n        \"height\": (1 + max_y - min_y) * cubeLength,\n        \"depth\": (1 + max_z - min_z) * cubeLength,\n    }\n\n\ndef detect_resolutions(dataset_path, layer) -> List[Mag]:\n    for mag in listdir(path.join(dataset_path, layer)):\n        try:\n            yield Mag(mag)\n        except ValueError:\n            logging.info(\"ignoring {} as resolution\".format(mag))\n\n\ndef detect_standard_layer(dataset_path, layer_name, exact_bounding_box=None):\n    # Perform metadata detection for well-known layers\n\n    if exact_bounding_box is None:\n        bbox = detect_bbox(dataset_path, layer_name)\n    else:\n        bbox = exact_bounding_box\n\n    dtype = detect_dtype(dataset_path, layer_name)\n\n    mags = list(detect_resolutions(dataset_path, layer_name))\n    mags = sorted(mags)\n    resolutions = [\n        {\n            \"resolution\": mag.to_array(),\n            \"cubeLength\": detect_cubeLength(dataset_path, layer_name, mag),\n        }\n        for mag in mags\n    ]\n\n    return {\n        \"dataFormat\": \"wkw\",\n        \"name\": layer_name,\n        \"category\": layer_name,\n        \"elementClass\": dtype,\n        \"boundingBox\": bbox,\n        \"wkwResolutions\": list(resolutions),\n    }\n\n\ndef detect_segmentation_layer(\n    dataset_path, layer_name, max_id, compute_max_id=False, exact_bounding_box=None\n):\n    layer_info = detect_standard_layer(dataset_path, layer_name, exact_bounding_box)\n    layer_info[\"mappings\"] = []\n    layer_info[\"largestSegmentId\"] = max_id\n\n    if compute_max_id:\n        logging.info(\"Computing max id of layer={}\".format(layer_name))\n        # Computing the current largest segment id\n        # This may take very long due to IO load\n        layer_path = path.join(dataset_path, layer_name, \"1\")\n        with wkw.Dataset.open(layer_path) as dataset:\n            bbox = layer_info[\"boundingBox\"]\n            layer_info[\"largestSegmentId\"] = int(\n                np.max(\n                    dataset.read(\n                        bbox[\"topLeft\"], [bbox[\"width\"], bbox[\"height\"], bbox[\"depth\"]]\n                    )\n                )\n            )\n            logging.info(\n                \"Max id of layer={} is {}\".format(\n                    layer_name, layer_info[\"largestSegmentId\"]\n                )\n            )\n\n    return layer_info\n\n\ndef detect_layers(dataset_path, max_id, compute_max_id, exact_bounding_box=None):\n    # Detect metadata for well-known layers, e.g. color and segmentation\n    if path.exists(path.join(dataset_path, \"color\")):\n        yield detect_standard_layer(dataset_path, \"color\", exact_bounding_box)\n    if path.exists(path.join(dataset_path, \"segmentation\")):\n        yield detect_segmentation_layer(\n            dataset_path, \"segmentation\", max_id, compute_max_id, exact_bounding_box\n        )\n\n\nif __name__ == \"__main__\":\n    logging.basicConfig(level=logging.DEBUG)\n    args = create_parser().parse_args()\n    scale = tuple(float(x) for x in args.scale.split(\",\"))\n    write_webknossos_metadata(\n        args.path, args.name, scale, args.max_id, args.compute_max_id\n    )\n", "path": "wkcuber/metadata.py"}], "after_files": [{"content": "import json\nimport re\nimport wkw\nimport logging\nimport numpy as np\n\nfrom argparse import ArgumentParser\nfrom glob import iglob\nfrom os import path, listdir\nfrom typing import Optional\nfrom .mag import Mag\nfrom typing import List\n\n\ndef create_parser():\n    parser = ArgumentParser()\n\n    parser.add_argument(\"path\", help=\"Directory containing the dataset.\")\n\n    parser.add_argument(\"--name\", \"-n\", help=\"Name of the dataset\")\n\n    parser.add_argument(\n        \"--scale\",\n        \"-s\",\n        help=\"Scale of the dataset (e.g. 11.2,11.2,25)\",\n        default=\"1,1,1\",\n    )\n\n    group = parser.add_mutually_exclusive_group()\n    group.add_argument(\n        \"--compute_max_id\",\n        \"-c\",\n        help=\"set to compute max id\",\n        default=False,\n        action=\"store_true\",\n    )\n    group.add_argument(\"--max_id\", help=\"set max id of segmentation.\", default=0)\n\n    return parser\n\n\ndef write_webknossos_metadata(\n    dataset_path,\n    name,\n    scale,\n    max_id=0,\n    compute_max_id=False,\n    exact_bounding_box: Optional[dict] = None,\n):\n\n    # Generate a metadata file for webKnossos\n    # Currently includes no source of information for team\n    datasource_properties_path = path.join(dataset_path, \"datasource-properties.json\")\n    layers = list(\n        detect_layers(dataset_path, max_id, compute_max_id, exact_bounding_box)\n    )\n    with open(datasource_properties_path, \"wt\") as datasource_properties_json:\n        json.dump(\n            {\n                \"id\": {\"name\": name, \"team\": \"<unknown>\"},\n                \"dataLayers\": layers,\n                \"scale\": scale,\n            },\n            datasource_properties_json,\n            indent=2,\n        )\n\n\ndef read_metadata_for_layer(wkw_path, layer_name):\n    datasource_properties = json.load(\n        open(path.join(wkw_path, \"datasource-properties.json\"), \"r\")\n    )\n    layers = datasource_properties[\"dataLayers\"]\n    layer_info = next(layer for layer in layers if layer[\"name\"] == layer_name)\n    dtype = np.dtype(layer_info[\"elementClass\"])\n    bounding_box = layer_info[\"boundingBox\"]\n    origin = bounding_box[\"topLeft\"]\n    bounding_box = [\n        bounding_box[\"width\"],\n        bounding_box[\"height\"],\n        bounding_box[\"depth\"],\n    ]\n\n    return layer_info, dtype, bounding_box, origin\n\n\ndef detect_dtype(dataset_path, layer, mag: Mag = Mag(1)):\n    layer_path = path.join(dataset_path, layer, str(mag))\n    if path.exists(layer_path):\n        with wkw.Dataset.open(layer_path) as dataset:\n            voxel_type = dataset.header.voxel_type\n            num_channels = dataset.header.num_channels\n            voxel_size = np.dtype(voxel_type)\n            if voxel_size == np.uint8 and num_channels > 1:\n                return \"uint\" + str(8 * num_channels)\n            else:\n                return str(np.dtype(voxel_type))\n\n\ndef detect_cubeLength(dataset_path, layer, mag: Mag = Mag(1)):\n    layer_path = path.join(dataset_path, layer, str(mag))\n    if path.exists(layer_path):\n        with wkw.Dataset.open(layer_path) as dataset:\n            return dataset.header.block_len * dataset.header.file_len\n\n\ndef detect_bbox(dataset_path, layer, mag: Mag = Mag(1)):\n    # Detect the coarse bounding box of a dataset by iterating\n    # over the WKW cubes\n    layer_path = path.join(dataset_path, layer, str(mag))\n\n    def list_files(layer_path):\n        return iglob(path.join(layer_path, \"*\", \"*\", \"*.wkw\"), recursive=True)\n\n    def parse_cube_file_name(filename):\n        CUBE_REGEX = re.compile(r\"z(\\d+)/y(\\d+)/x(\\d+)(\\.wkw)$\")\n        m = CUBE_REGEX.search(filename)\n        return (int(m.group(3)), int(m.group(2)), int(m.group(1)))\n\n    def list_cubes(layer_path):\n        return (parse_cube_file_name(f) for f in list_files(layer_path))\n\n    xs, ys, zs = list(zip(*list_cubes(layer_path)))\n\n    min_x, min_y, min_z = min(xs), min(ys), min(zs)\n    max_x, max_y, max_z = max(xs), max(ys), max(zs)\n\n    cubeLength = detect_cubeLength(dataset_path, layer, mag)\n\n    return {\n        \"topLeft\": [min_x * cubeLength, min_y * cubeLength, min_z * cubeLength],\n        \"width\": (1 + max_x - min_x) * cubeLength,\n        \"height\": (1 + max_y - min_y) * cubeLength,\n        \"depth\": (1 + max_z - min_z) * cubeLength,\n    }\n\n\ndef detect_resolutions(dataset_path, layer) -> List[Mag]:\n    for mag in listdir(path.join(dataset_path, layer)):\n        try:\n            yield Mag(mag)\n        except ValueError:\n            logging.info(\"ignoring {} as resolution\".format(mag))\n\n\ndef detect_standard_layer(dataset_path, layer_name, exact_bounding_box=None):\n    # Perform metadata detection for well-known layers\n\n    if exact_bounding_box is None:\n        bbox = detect_bbox(dataset_path, layer_name)\n    else:\n        bbox = exact_bounding_box\n\n    mags = list(detect_resolutions(dataset_path, layer_name))\n    mags = sorted(mags)\n    resolutions = [\n        {\n            \"resolution\": mag.to_array(),\n            \"cubeLength\": detect_cubeLength(dataset_path, layer_name, mag),\n        }\n        for mag in mags\n    ]\n\n    assert len(mags) > 0, \"No resolutions found\"\n    dtype = detect_dtype(dataset_path, layer_name, mags[0])\n\n    return {\n        \"dataFormat\": \"wkw\",\n        \"name\": layer_name,\n        \"category\": layer_name,\n        \"elementClass\": dtype,\n        \"boundingBox\": bbox,\n        \"wkwResolutions\": list(resolutions),\n    }\n\n\ndef detect_segmentation_layer(\n    dataset_path, layer_name, max_id, compute_max_id=False, exact_bounding_box=None\n):\n    layer_info = detect_standard_layer(dataset_path, layer_name, exact_bounding_box)\n    layer_info[\"mappings\"] = []\n    layer_info[\"largestSegmentId\"] = max_id\n\n    if compute_max_id:\n        logging.info(\"Computing max id of layer={}\".format(layer_name))\n        # Computing the current largest segment id\n        # This may take very long due to IO load\n        layer_path = path.join(dataset_path, layer_name, \"1\")\n        with wkw.Dataset.open(layer_path) as dataset:\n            bbox = layer_info[\"boundingBox\"]\n            layer_info[\"largestSegmentId\"] = int(\n                np.max(\n                    dataset.read(\n                        bbox[\"topLeft\"], [bbox[\"width\"], bbox[\"height\"], bbox[\"depth\"]]\n                    )\n                )\n            )\n            logging.info(\n                \"Max id of layer={} is {}\".format(\n                    layer_name, layer_info[\"largestSegmentId\"]\n                )\n            )\n\n    return layer_info\n\n\ndef detect_layers(dataset_path, max_id, compute_max_id, exact_bounding_box=None):\n    # Detect metadata for well-known layers, e.g. color and segmentation\n    if path.exists(path.join(dataset_path, \"color\")):\n        yield detect_standard_layer(dataset_path, \"color\", exact_bounding_box)\n    if path.exists(path.join(dataset_path, \"segmentation\")):\n        yield detect_segmentation_layer(\n            dataset_path, \"segmentation\", max_id, compute_max_id, exact_bounding_box\n        )\n\n\nif __name__ == \"__main__\":\n    logging.basicConfig(level=logging.DEBUG)\n    args = create_parser().parse_args()\n    scale = tuple(float(x) for x in args.scale.split(\",\"))\n    write_webknossos_metadata(\n        args.path, args.name, scale, args.max_id, args.compute_max_id\n    )\n", "path": "wkcuber/metadata.py"}]}