Skip to content

icp-log-viewer: add --min-quality filter CLI flag#52

Merged
jlblancoc merged 1 commit intodevelopfrom
icp-log-viewer-quality-filter
Apr 9, 2026
Merged

icp-log-viewer: add --min-quality filter CLI flag#52
jlblancoc merged 1 commit intodevelopfrom
icp-log-viewer-quality-filter

Conversation

@jlblancoc
Copy link
Copy Markdown
Member

@jlblancoc jlblancoc commented Apr 9, 2026

Summary by CodeRabbit

  • New Features

    • Added a -q/--min-quality CLI option to filter ICP logs by minimum quality (0–1). Logs below the threshold are skipped with console warnings; a kept/total summary is shown and an error is reported if no files remain after filtering.
  • Documentation

    • Updated docs with usage examples for the quality filter and expanded GUI descriptions (control panel, navigation, 3D viewport, stats, and pairings visualization).

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9b54e2c8-337c-4b16-8a17-7b05f1c3d159

📥 Commits

Reviewing files that changed from the base of the PR and between 0e0e542 and a59cfe4.

📒 Files selected for processing (2)
  • apps/icp-log-viewer/main.cpp
  • docs/source/app_icp-log-viewer.rst
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/icp-log-viewer/main.cpp

📝 Walkthrough

Walkthrough

Added a CLI option -q/--min-quality to icp-log-viewer that filters discovered/selected .icplog files at load time by their icpResult.quality values, logs skipped files and a summary, and errors if no files remain after filtering; documentation updated with usage examples.

Changes

Cohort / File(s) Summary
ICP Quality Filtering
apps/icp-log-viewer/main.cpp
Added -q/--min-quality CLI arg (double, default 0.0, range [0,1]). Validates input, attempts per-file load into mp2p_icp::LogRecord (skips and warns on load failure), filters out files with lr.icpResult.quality < minQ (logs skips), prints "kept X / Y files", throws if none remain, and uses the filtered list for subsequent logRecords population.
Documentation Updates
docs/source/app_icp-log-viewer.rst
Rewrote placeholder with detailed GUI and feature documentation. Added CLI usage examples including -q/--min-quality, explained filtering behavior and examples, and refined inline formatting for identifiers.

Sequence Diagram

sequenceDiagram
    actor User
    participant CLI as CLI Parser
    participant Main as main_show_gui()
    participant Loader as LogRecord Loader
    participant FileList as Filtered Files

    User->>CLI: Launch with --min-quality
    CLI->>Main: Provide minQ
    Main->>Main: Validate 0.0 <= minQ <= 1.0
    loop for each candidate file
        Main->>Loader: LoadFromFile(candidate)
        alt Load fails
            Loader-->>Main: error
            Main->>Main: Log warning, skip file
        else Load succeeds
            Loader-->>Main: LogRecord (icpResult.quality)
            Main->>Main: Compare quality >= minQ?
            alt Passes
                Main->>FileList: Add file
            else Fails
                Main->>Main: Log skip to stderr
            end
        end
    end
    Main->>Main: Print "kept N / total" summary
    alt No files kept
        Main->>Main: Throw exception mentioning --min-quality
    end
    Main->>Main: Use filtered FileList for logRecords population
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 I nibble through logs with keen delight,
A threshold set, I hop to find the bright,
Files below the bar I kindly toss,
Kept ones parade across my mossy cross,
Docs sing guidance as the viewer takes flight.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'icp-log-viewer: add --min-quality filter CLI flag' directly and clearly describes the main change: adding a new CLI option for quality filtering to the icp-log-viewer application.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch icp-log-viewer-quality-filter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/icp-log-viewer/main.cpp`:
- Around line 245-246: Validate the CLI value returned by
argMinQuality.getValue() before using it: read the value into minQ, check that
minQ is within [0.0, 1.0], and if not, print a clear error and exit non-zero (or
throw) instead of proceeding; update the std::cout line to only run after the
check. Reference argMinQuality.getValue(), the local variable minQ, and the
existing print/exit path in main (where the current std::cout lives) when adding
the range check and error handling.
- Around line 270-273: After applying the quality filter (where filteredFiles is
moved into files), check if files.empty() and handle that case with a clear
user-facing failure instead of letting execution hit
ASSERT_(!logRecords.empty()). Specifically, in the block around the use of
filteredFiles/files (the code that prints "Quality filter: kept ..."), detect
when files.empty(), print a helpful error message explaining that no files
passed the quality filter, and exit gracefully with a non-zero status (or return
an error) so downstream asserts are never triggered.
- Around line 251-268: LoadFromFile() doesn't throw on failure and returns a
default LogRecord, so stop relying on the try/catch and instead call the
lower-level load_from_file() that returns a bool; if
load_from_file(file.wholePath, out_lr) returns false, write the warning using
file.wholePath and file.name and skip pushing to filteredFiles, otherwise use
out_lr.icpResult.quality to compare with minQ and push to filteredFiles. Locate
references to LogRecord::LoadFromFile, load_from_file(), lr.icpResult.quality,
filteredFiles, file.wholePath and file.name to implement the change.

In `@docs/source/app_icp-log-viewer.rst`:
- Around line 132-134: The docs incorrectly suggest using --min-quality 0.0 to
inspect low-quality registrations; --min-quality is a lower bound and 0.0 will
load everything. Update the explanatory text and the example command to use the
correct flag and value for low-quality filtering (e.g., change the comment and
command to mention inspecting only registrations with quality <20% by using
--max-quality 0.2 with the icp-log-viewer command), and ensure the description
refers to --max-quality rather than --min-quality.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5b0c3d67-a3de-4844-a58e-357434b9be82

📥 Commits

Reviewing files that changed from the base of the PR and between 37628b0 and 541db35.

📒 Files selected for processing (2)
  • apps/icp-log-viewer/main.cpp
  • docs/source/app_icp-log-viewer.rst

Comment thread apps/icp-log-viewer/main.cpp
Comment thread apps/icp-log-viewer/main.cpp Outdated
Comment thread apps/icp-log-viewer/main.cpp
Comment thread docs/source/app_icp-log-viewer.rst
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.60%. Comparing base (37628b0) to head (a59cfe4).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #52      +/-   ##
===========================================
- Coverage    78.60%   78.60%   -0.01%     
===========================================
  Files          190      190              
  Lines        10573    10572       -1     
  Branches       977      977              
===========================================
- Hits          8311     8310       -1     
  Misses        2262     2262              

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jlblancoc jlblancoc force-pushed the icp-log-viewer-quality-filter branch from 541db35 to 0e0e542 Compare April 9, 2026 08:04
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
apps/icp-log-viewer/main.cpp (1)

274-281: ⚠️ Potential issue | 🟠 Major

Check emptiness after applying the filter result, not before.

files.empty() is evaluated before files is replaced with filteredFiles, so the “no files passed” case is still missed and later hits ASSERT_(!logRecords.empty()).

Proposed fix
-        if (files.empty())
-        {
-            THROW_EXCEPTION_FMT(
-                "No log files passed --min-quality=%.03f. Lower the threshold or check input logs.",
-                minQ);
-        }
-
         files = std::move(filteredFiles);
+        if (files.empty())
+        {
+            THROW_EXCEPTION_FMT(
+                "No log files passed --min-quality=%.03f. Lower the threshold or check input logs.",
+                minQ);
+        }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/icp-log-viewer/main.cpp` around lines 274 - 281, The check for empty
input uses files.empty() before files is replaced with filteredFiles, so the “no
log files passed” path can be missed; change the logic in main (the block around
files, filteredFiles, minQ) to first assign files = std::move(filteredFiles) and
then call THROW_EXCEPTION_FMT when files.empty(), i.e. evaluate emptiness after
the move so the minQ-based filtering result is honored. Ensure you reference the
same variables (files, filteredFiles, minQ) and keep the error text unchanged.
docs/source/app_icp-log-viewer.rst (1)

123-134: ⚠️ Potential issue | 🟡 Minor

The low-quality example is still misleading.

--min-quality 0.0 does not isolate low-quality runs; it effectively loads all files.

Proposed fix
-When a directory contains many log files (e.g. from a full SLAM session) it is often
-useful to inspect only the low-quality registrations that may have caused drift.  Use
-``--min-quality`` to restrict the loaded set:
+When a directory contains many log files (e.g. from a full SLAM session), use
+``--min-quality`` as a lower-bound filter to focus on higher-confidence results:
@@
-    # Inspect only low-quality (< 20 %) registrations — invert by running with 0
-    # and then sorting/filtering externally, or set a low threshold and browse manually
+    # Note: --min-quality is a lower bound. Using 0.0 loads all files.
+    # To inspect low-quality-only runs, post-filter externally.
     icp-log-viewer -d logs/ --min-quality 0.0
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/source/app_icp-log-viewer.rst` around lines 123 - 134, The docs example
is misleading: `--min-quality 0.0` does not isolate low-quality runs (it loads
all files). Update the second example and its explanatory text to show the
correct flag/approach for selecting low-quality registrations (e.g., use
`--max-quality 0.2` to inspect <20% runs) and remove or reword the suggestion
about inverting by running with 0; reference the CLI flags `--min-quality` and
`--max-quality` and the `icp-log-viewer` example lines so the sample and
description match actual behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/icp-log-viewer/main.cpp`:
- Around line 80-82: The CLI help string passed to the ValueArg for the ICP
quality threshold contains doubled percent signs ("0%%-100%%"); update the
literal to use single percent characters ("0%-100%") so the help displays
"0%-100%" correctly; locate the ValueArg construction that includes the text
"Minimum ICP quality..." in main.cpp and replace the doubled "%%" occurrences in
that help string with single "%" characters.

---

Duplicate comments:
In `@apps/icp-log-viewer/main.cpp`:
- Around line 274-281: The check for empty input uses files.empty() before files
is replaced with filteredFiles, so the “no log files passed” path can be missed;
change the logic in main (the block around files, filteredFiles, minQ) to first
assign files = std::move(filteredFiles) and then call THROW_EXCEPTION_FMT when
files.empty(), i.e. evaluate emptiness after the move so the minQ-based
filtering result is honored. Ensure you reference the same variables (files,
filteredFiles, minQ) and keep the error text unchanged.

In `@docs/source/app_icp-log-viewer.rst`:
- Around line 123-134: The docs example is misleading: `--min-quality 0.0` does
not isolate low-quality runs (it loads all files). Update the second example and
its explanatory text to show the correct flag/approach for selecting low-quality
registrations (e.g., use `--max-quality 0.2` to inspect <20% runs) and remove or
reword the suggestion about inverting by running with 0; reference the CLI flags
`--min-quality` and `--max-quality` and the `icp-log-viewer` example lines so
the sample and description match actual behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 59556ed0-3486-43b5-8412-eb567a8b8333

📥 Commits

Reviewing files that changed from the base of the PR and between 541db35 and 0e0e542.

📒 Files selected for processing (2)
  • apps/icp-log-viewer/main.cpp
  • docs/source/app_icp-log-viewer.rst

Comment thread apps/icp-log-viewer/main.cpp Outdated
@jlblancoc jlblancoc force-pushed the icp-log-viewer-quality-filter branch from 0e0e542 to a59cfe4 Compare April 9, 2026 08:20
@jlblancoc jlblancoc enabled auto-merge April 9, 2026 08:20
@jlblancoc jlblancoc merged commit 63cc0fd into develop Apr 9, 2026
13 checks passed
@jlblancoc jlblancoc deleted the icp-log-viewer-quality-filter branch April 9, 2026 08:34
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.

1 participant