Support filename pattern grouping in cross-validation CLI#406
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR completes wiring of the filename-pattern cross-validation grouping strategy into the jabs-cli cross-validation command, allowing the strategy and its regex to be selected/configured via CLI and ensuring the training report reflects the effective settings actually used.
Changes:
- Extended
--grouping-strategyto includefilenameand added--grouping-patternfor the regex override. - Threaded an optional
grouping_regexthroughrun_cross_validation()intoProject.get_labeled_features(). - Updated report generation to record the effective grouping strategy/regex (CLI override → project settings), emitting the regex only for filename-pattern grouping.
- Added CLI parsing tests using a
run_cross_validationspy for fast option→argument verification.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/jabs/scripts/cli/cli.py |
Adds filename grouping option, --grouping-pattern, and maps CLI strings to the enum; forwards regex override. |
src/jabs/scripts/cli/cross_validation.py |
Adds grouping_regex parameter, forwards to feature extraction, and records effective grouping settings in the report. |
tests/scripts/test_cross_validation_cli.py |
New tests validating Click parsing/mapping and argument forwarding to run_cross_validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
The filename-pattern cross-validation grouping strategy (added in #398) was wired into the GUI,
Project.get_labeled_features, and project settings, but thejabs-cli cross-validationcommand was left incomplete — there was no way to select or configure it from the CLI. This PR closes that gap.What was missing
--grouping-strategyonly acceptedvideoandindividual—FILENAME_PATTERNwas unreachable.run_cross_validationhad nogrouping_regexparameter, so even if the strategy could be selected, no regex could reach the layer that requires it (compile_grouping_regexraises on an empty pattern).Changes
scripts/cli/cli.pyfilenameto the--grouping-strategychoices.--grouping-patternoption for the regex (falls back to the project's saved pattern when omitted).grouping_regex.scripts/cli/cross_validation.pygrouping_regex: str | Noneparameter, documented it, and passed it toget_labeled_features.FILENAME_PATTERN(also fixes a pre-existing minor issue where a stale saved regex could appear in the report for non-filename strategies).tests/scripts/test_cross_validation_cli.py(new)Nonedefaults, and rejection of unknown strategies, using arun_cross_validationspy so they're fast and need no real project.Example
Testing
test_cv_groupingin core and project): 23 passed total.ruff checkclean;ruff formatapplied.jabs-cli cross-validation --helprenders both new options correctly.