Skip to content

fix: bound discovery memory and route generator warnings through logging#113

Merged
tompollard merged 1 commit into
MIT-LCP:mainfrom
elementalcollision:chimera/robustness-logging
Jul 1, 2026
Merged

fix: bound discovery memory and route generator warnings through logging#113
tompollard merged 1 commit into
MIT-LCP:mainfrom
elementalcollision:chimera/robustness-logging

Conversation

@elementalcollision

@elementalcollision elementalcollision commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Draft PR opened by Chimera (an autonomous code agent operated by @elementalcollision), as part of a review of croissant-baker. Opened as a draft for maintainer review.

Two small robustness/consistency fixes, bundled.

1. Bounded-memory file discovery

files.discover_files appended every hidden-directory path to skipped_examples, a list used only to print a few examples in a debug log. On a dataset with a large hidden tree — an accidental .git, a big .ipynb_checkpoints — that list grows without bound for output we only ever sample. Cap retained examples at 5; the skipped count stays exact.

2. Consistent observability (logging, not print)

Every file handler already logs through a module logger (croissant_baker.handlers.*), but metadata_generator emitted its warnings via print() to stdout. This routes the three warning-level diagnostics — failed extraction, failed build_croissant, multi-match field mapping — through a croissant_baker.metadata_generator logger: off stdout, controllable, and consistent with the handlers.

The DICOM skip summary deliberately stays a stdout print — it's a user-facing summary line with its own dedicated test (test_dicom_skip_summary_printed_…), not a warning.

Tests

  • New cap assertion in test_files.py (20 hidden files → exact count, 5 examples).
  • New test_generator_diagnostics.py: the field-mapping warning is emitted on the logger.
  • The existing field-mapping CLI test now asserts via caplog — the same pattern the parquet/image/fhir handler-warning tests already use.
  • Full suite: 271 passed. No change to committed tests/data/output/*.jsonld.

Note on overlap

This touches the same metadata_generator.py "Failed to process" warning line that #112 (parallel extraction) relocates. The two overlap by one line; whichever merges second needs a trivial rebase. The changes are otherwise independent.

Two small robustness/consistency fixes in one change:

- files.discover_files appended every hidden-directory path to an in-memory
  list used only for a debug log, so a dataset with a large hidden tree (a
  stray .git or .ipynb_checkpoints) grew the list without bound. Cap the
  retained examples at 5; the skipped count stays exact.

- metadata_generator emitted its warnings via print() to stdout, while every
  file handler already logs through a module logger. Route the three
  warning-level diagnostics (failed extraction, failed build_croissant,
  multi-match field mapping) through a module logger instead -- off stdout and
  controllable, matching the handler convention. The DICOM skip summary stays a
  stdout print: it is a deliberate user-facing summary with its own test.

Tests: cap assertion in test_files; logging assertion in
test_generator_diagnostics; the existing field-mapping CLI test now asserts via
caplog, like the handler-warning tests already do. Full suite (271) passes with
no change to committed example outputs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@rafiattrach rafiattrach left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! That seems reasonable!

@tompollard
tompollard merged commit 84f925c into MIT-LCP:main Jul 1, 2026
3 checks passed
@elementalcollision
elementalcollision deleted the chimera/robustness-logging branch July 1, 2026 16:45
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.

3 participants