fix: move unique_repos tracking before file changes check to prevent KeyError #71
+8
−3
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.
Problem
Fixes #66
The apply_cross_miner_multipliers_and_finalize function crashes with KeyError when a PR has no file changes.
Root Cause
In score_pull_requests, the line:
miner_eval.unique_repos_contributed_to.add(pr.repository_full_name)
was placed AFTER the continue statement that skips PRs with no file changes. This means PRs without file changes never get their repository added to unique_repos_contributed_to.
Later, apply_cross_miner_multipliers_and_finalize tries to access repo_counts[pr.repository_full_name] which raises KeyError because the repo was never counted.
Fix
Move unique_repos_contributed_to.add() to the beginning of the loop, before the file changes check. This ensures ALL valid PRs contribute to repository uniqueness regardless of whether they have file changes.
Impact
Contribution by Gittensor, learn more at https://gittensor.io/