Skip to content

Commit 21fd7fa

Browse files
committed
ENH: organize - show files with conflicts requiring adding _obj-
Logging check is currently not really functioning since IIRC we do enable logging into a file at higher level than INFO. So we might need to tune decision making here
1 parent 44e097f commit 21fd7fa

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

dandi/organize.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from collections.abc import Sequence
1010
from copy import deepcopy
1111
from enum import Enum
12+
import logging
1213
import os
1314
import os.path as op
1415
from pathlib import Path, PurePosixPath
@@ -307,9 +308,28 @@ def _assign_obj_id(metadata, non_unique):
307308
# Avoid heavy import by importing within function:
308309
from .pynwb_utils import get_object_id
309310

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

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")
313333
seen_obj_ids = {} # obj_id: object_id
314334
seen_object_ids = {} # object_id: path
315335
recent_nwb_msg = "NWB>=2.1.0 standard (supported by pynwb>=1.1.0)."

0 commit comments

Comments
 (0)