|
9 | 9 | from collections.abc import Sequence |
10 | 10 | from copy import deepcopy |
11 | 11 | from enum import Enum |
| 12 | +import logging |
12 | 13 | import os |
13 | 14 | import os.path as op |
14 | 15 | from pathlib import Path, PurePosixPath |
@@ -307,9 +308,28 @@ def _assign_obj_id(metadata, non_unique): |
307 | 308 | # Avoid heavy import by importing within function: |
308 | 309 | from .pynwb_utils import get_object_id |
309 | 310 |
|
310 | | - msg = "%d out of %d paths are not unique" % (len(non_unique), len(metadata)) |
| 311 | + msg = "%d out of %d paths are not unique." % (len(non_unique), len(metadata)) |
| 312 | + non_unique_paths = sorted(non_unique) |
311 | 313 |
|
312 | | - lgr.info(msg + ". We will try adding _obj- based on crc32 of object_id") |
| 314 | + # provide more information to the user |
| 315 | + def get_msg(path, indent=" "): |
| 316 | + in_paths = non_unique[path] |
| 317 | + return ( |
| 318 | + f"{len(in_paths)} paths 'compete' for the path {path!r}:" |
| 319 | + + f"\n{indent}".join([""] + in_paths) |
| 320 | + ) |
| 321 | + |
| 322 | + msg += "\n " + get_msg(non_unique_paths[0]) |
| 323 | + if len(non_unique) > 1: |
| 324 | + if not lgr.isEnabledFor(logging.DEBUG): |
| 325 | + msg += ( |
| 326 | + " Rerun with logging at DEBUG level '-l debug' " |
| 327 | + "to see {len(non_unique) - 1} more cases." |
| 328 | + ) |
| 329 | + else: |
| 330 | + for ex_path in non_unique_paths[1:]: |
| 331 | + msg += "\n " + get_msg(ex_path) |
| 332 | + lgr.info(msg + " We will try adding _obj- based on crc32 of object_id") |
313 | 333 | seen_obj_ids = {} # obj_id: object_id |
314 | 334 | seen_object_ids = {} # object_id: path |
315 | 335 | recent_nwb_msg = "NWB>=2.1.0 standard (supported by pynwb>=1.1.0)." |
|
0 commit comments