Add CLI threshold override#2129
Open
mturac wants to merge 2 commits into
Open
Conversation
8193c35 to
9610831
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a --threshold override to presidio-cli, allowing one-off runs to set the minimum confidence score without editing or generating a YAML configuration file, aligning with the requested behavior in #2101.
Changes:
- Added a
--thresholdCLI flag with 0..1 validation and applied it after config loading so it overrides configured values. - Added unit tests covering threshold override behavior and CLI value validation.
- Updated CLI documentation and added an Unreleased changelog entry for the new flag.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| presidio-cli/presidio_cli/cli.py | Adds --threshold parsing/validation and applies it as a post-config override. |
| presidio-cli/tests/test_cli.py | Adds tests for threshold override precedence and threshold input validation. |
| presidio-cli/README.md | Documents the config threshold field and shows an example of overriding it via --threshold. |
| CHANGELOG.md | Records the new CLI flag under Unreleased changes. |
Comment on lines
+114
to
+117
| config_data="threshold: 0.2", | ||
| config_file=None, | ||
| files="", | ||
| threshold=0.8, |
Comment on lines
+136
to
+140
| stdin=True, | ||
| config_data=None, | ||
| config_file=str(config_file), | ||
| files="", | ||
| threshold=0.8, |
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.
Change Description
Adds a
--thresholdoption topresidio-cli, validates it as a 0..1 confidence score, and applies it after loading the selected configuration so one-off runs can override the configured threshold without inline YAML or a temporary config file.Also documents the flag and records the change in the unreleased changelog.
Issue reference
Fixes #2101
Tests
uv run --project presidio-cli --python python3.13 --with pytest --with pytest-mock pytest presidio-cli/tests -quv run --project presidio-cli --python python3.13 --with 'ruff==0.9.2' ruff check\n-printf 'hello\\n' | uv run --project presidio-cli --python python3.13 presidio --threshold 0.7 -\n\n## Checklist\n\n- [x] I have reviewed the contribution guidelines\n- [ ] I have signed the CLA (if required)\n- [x] My code includes unit tests\n- [x] All unit tests and lint checks pass locally\n- [x] My PR contains documentation updates / additions if required\n