Skip to content

Say why metadata failed to load and how to see the tracebacks - #1901

Open
adityasingh2400 wants to merge 1 commit into
dandi:masterfrom
adityasingh2400:fix-1640
Open

Say why metadata failed to load and how to see the tracebacks#1901
adityasingh2400 wants to merge 1 commit into
dandi:masterfrom
adityasingh2400:fix-1640

Conversation

@adityasingh2400

Copy link
Copy Markdown

Fixes #1640

dandi organize warned Failed to load metadata for N out of M files due to following types of exceptions: ConstructError. Details of the exceptions will be shown at DEBUG level and stopped there. The user got an exception class name, no reason, and no hint about how to reach DEBUG level or where the log file lives. As the reporter notes, most people running organize are not programmers.

The warning now names each offending path with its exception type and the exception's own message, capped at MAX_METADATA_ERRORS_SHOWN = 5 so a large batch does not flood the console. It also says that full tracebacks are written to the log file, and that dandi --log-level DEBUG organize ... prints them to the console.

The message is built by format_metadata_load_failures() so it can be tested without running a full organize.

Verified against the base ref. On master the integration test fails because the reason never appears in the warnings. On this branch it does. One note on that check: the two unit tests import the new symbols, so a plain revert fails at collection rather than on behavior. To get a genuinely behavioral before signal I reverted organize.py to the base ref and also removed the two new imports from the test file, then ran only the integration test, which fails on the old message content. Both were restored afterward.

New tests are marked @pytest.mark.ai_generated. dandi/tests/test_organize.py excluding integration gives 34 passed, 14 deselected.

AI assistance disclosure: this change was written with the help of Claude Code, and the added tests are marked ai_generated as CLAUDE.md asks. I reviewed and tested everything before submitting.

`dandi organize` warned "Failed to load metadata for N out of M files due
to following types of exceptions: ConstructError. Details of the
exceptions will be shown at DEBUG level" and stopped there. The user got
an exception class name, no reason, and no way to find out how to reach
DEBUG level. Most people running organize are not programmers and do not
know about log levels or where the log file lives.

The warning now names each offending path with its exception type and
the exception's own message, capped at MAX_METADATA_ERRORS_SHOWN so a
large batch does not flood the console, and it says that full tracebacks
are in the log file and that 'dandi --log-level DEBUG organize ...'
prints them to the console.

The message is built by `format_metadata_load_failures()` so it can be
tested without running a full organize.

Closes dandi#1640
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unclear error for files with timestamps that are not timezone aware with dandi organize

1 participant