Skip to content

Add model prediction and rule integration - #3

Open
Kaushik-Kumar-CEG wants to merge 8 commits into
gsoc/training-pipelinefrom
gsoc/prediction-injection
Open

Kaushik-Kumar-CEG wants to merge 8 commits into
gsoc/training-pipelinefrom
gsoc/prediction-injection

Conversation

@Kaushik-Kumar-CEG

@Kaushik-Kumar-CEG Kaushik-Kumar-CEG commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Adds reusable APIs for model-assisted ScanCode rule updates.

The APIs load eligible rules, validate model predictions with ScanCode, prepare complete updates without changing the input rule, and atomically write the exact source path. Unsafe candidates, protected URLs and filenames, repeated phrases, overlapping phrases, stale files, and unsafe model artifacts are rejected.

Example:

from scancode_required_phrases.model_rules import load_prediction_rule
from scancode_required_phrases.model_rules import predict_rule_candidates

rule_path, rule = load_prediction_rule("path/to/example.RULE")
result, candidates = predict_rule_candidates(rule, predictor)

Test it:

./configure --dev
python -m pip install -e ".[inference]"
venv/bin/pytest -q tests/test_model_rules.py tests/test_inference.py
venv/bin/ruff check src tests

This PR is stacked on PR #2. PR #4 uses these APIs for the user command.

Signed-off-by: Kaushik Kumar <kaushikrjpm10@gmail.com>
Signed-off-by: Kaushik <kaushikrjpm10@gmail.com>
Signed-off-by: Kaushik <kaushikrjpm10@gmail.com>
Signed-off-by: Kaushik <kaushikrjpm10@gmail.com>
Signed-off-by: Kaushik <kaushikrjpm10@gmail.com>
Signed-off-by: Kaushik <kaushikrjpm10@gmail.com>
Signed-off-by: Kaushik Kumar <kaushikrjpm10@gmail.com>
Signed-off-by: Kaushik <kaushikrjpm10@gmail.com>
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