Refactor profiles filtering: add rank_profile, get_matching_profiles, get_highest_score_profiles#1705
Open
vincentullmann wants to merge 2 commits intoynput:developfrom
Conversation
vincentullmann
commented
Feb 16, 2026
|
|
||
| def _profile_exclusion(matching_profiles, logger): | ||
| """Find out most matching profile byt host, task and family match. | ||
| def fullmatch(regex, string, flags=0): |
Contributor
Author
There was a problem hiding this comment.
this function is unchanged. the diff is incorrect
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.
Changelog Description
Refactored profile filtering and added new methods so callers can match multiple profiles instead of only picking the single best one.
Additional info
Unchanged
filter_profilesexpected behaviour is unchanged and backwards compatible. (hopefully)New
rank_profile: ranks a single profile using a lexicographic binary score.1= exact match,0= wildcard); results form a bitmask so earlier keys matter more.0b110 = 6beats0b101 = 5(both have 2 value matches and 1 wildcard).1bits (e.g.score.bit_count()).rank_profiles: helper to rank multiple profilesget_matching_profiles: returns all profiles with a non‑negative score.get_highest_score_profiles: Returns all profiles with the highest score.Use case
Useful for addons that want to compose profiles dynamically (eg. merge multiple rules into one).
Example (eg. dynamic profiles for deadline):