test: cover docling-tools CLI, profiling and debug visualization - #4046
Open
dolfim-ibm wants to merge 3 commits into
Open
test: cover docling-tools CLI, profiling and debug visualization#4046dolfim-ibm wants to merge 3 commits into
dolfim-ibm wants to merge 3 commits into
Conversation
The --quiet flag documents that "no extra output is generated, the CLI prints only the directory with the cached models", and the sibling `download` command behaves that way. `download-hf-repo` printed a per-repo progress line regardless, so its quiet output could not be consumed as a plain path. Adds tests for the `docling-tools models` option surface, which had no coverage at all: the downloaders are replaced with recorders so the tests assert which model selection the CLI derives from a given set of flags, rather than asserting on the calls themselves. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
Both modules sit behind settings.debug flags that no test enables, so neither was exercised: utils/profiling.py at 37% and utils/visualization.py at 13% line coverage. The profiling tests drive the TimeIntervalRecorder state machine and its error paths in both the enabled and disabled states. The visualization tests render synthetic clusters onto a real page image and assert on the resulting pixels, the region-label split between the two halves, and the debug output paths. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
Contributor
|
✅ DCO Check Passed Thanks @dolfim-ibm, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The CLI tests normalised Rich's box drawing and line wrapping but not its
colour codes. Rich only emits those when the output stream is a terminal,
so the tests passed locally and failed under CI, where an escape sequence
lands between the wrapped halves of the message and keeps the expected
phrase from ever matching:
requires the 'easyocr' \x1b[31m \x1b[0m \x1b[31m \x1b[0m model
Strips the escapes before collapsing whitespace, and routes the offline
usage hint through the same helper -- it wraps for the same reason.
Verified with colour forced on at 80 and 50 columns as well as with
colour off.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second iteration of the coverage work started in #4044. Targets three modules that had no test reaching them at all, and fixes one bug the new tests surfaced.
Coverage
Measured in the core lane with
--cov-branch:utils/visualization.pyutils/profiling.pycli/models.pycli/tools.pycli/tools.pycannot go much higher: 14 of its 21 statements are anImportErrorfallback that only runs whentyperis absent, which never happens in CI.Why these were dark
utils/profiling.pyandutils/visualization.pysit behindsettings.debug.*flags that default toFalse, and no test enables them.docling-tools(cli/tools.py→cli/models.py) was never imported by any test in the core lane.The fix
docling-tools models download-hf-repo --quietprinted a per-repo progress line even though--quietdocuments "no extra output is generated, the CLI prints only the directory with the cached models". The siblingdownloadcommand already behaved correctly, so quiet output could not be consumed as a plain path.Approach
The CLI tests replace the downloader entry points with recorders and assert which model selection the CLI derives from a given set of flags — the option-plumbing contract — rather than asserting on the calls themselves. No model is downloaded.
The visualization tests render synthetic clusters onto a real page image and assert on resulting pixels, the region-label split between the two halves, scale factors, inverted-box normalisation, and the debug output paths. The profiling tests drive the
TimeIntervalRecorderstate machine and its error paths in both the enabled and disabled states.Notes
fix:ships via semantic-release, thetest:commit does not.pyproject.tomloruv.lockchanges.🤖 Generated with Claude Code