Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions gittensor/utils/github_api_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ def _fetch_file_contents_with_base_batch(
head_sha: str,
batch_changes: List['FileChangeType'],
token: str,
pr_number: Optional[int] = None,
) -> Dict[str, FileContentPair]:
"""Fetch base and head file contents for a single batch of file changes.

Expand Down Expand Up @@ -1192,7 +1193,8 @@ def _fetch_file_contents_with_base_batch(

data = execute_graphql_query(query, variables, token)
if data is None:
bt.logging.warning(f'Failed to fetch file contents for {repo_owner}/{repo_name}')
ctx = f' (PR #{pr_number})' if pr_number else ''
bt.logging.warning(f'Failed to fetch file contents for {repo_owner}/{repo_name}{ctx}')
return {fc.filename: FileContentPair(None, None) for fc in batch_changes}

if 'errors' in data:
Expand Down Expand Up @@ -1229,6 +1231,7 @@ def fetch_file_contents_with_base(
head_sha: str,
file_changes: List['FileChangeType'],
token: str,
pr_number: Optional[int] = None,
) -> Dict[str, FileContentPair]:
"""Fetch old and new versions of files in batches so large PRs don't hit complexity limits.

Expand All @@ -1250,7 +1253,9 @@ def fetch_file_contents_with_base(

for batch_start in range(0, len(file_changes), MAX_FILES_PER_GRAPHQL_BATCH):
batch = file_changes[batch_start : batch_start + MAX_FILES_PER_GRAPHQL_BATCH]
batch_results = _fetch_file_contents_with_base_batch(repo_owner, repo_name, base_sha, head_sha, batch, token)
batch_results = _fetch_file_contents_with_base_batch(
repo_owner, repo_name, base_sha, head_sha, batch, token, pr_number=pr_number
)
results.update(batch_results)

return results
4 changes: 3 additions & 1 deletion gittensor/validator/oss_contributions/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ def fetch_file_contents_for_pr(pr: PullRequest, github_pat: str) -> Dict[str, Fi
f'PR #{pr.number}: using merge-base {merge_base[:8]} instead of base_ref {pr.base_ref_oid[:8]}'
)

return fetch_file_contents_with_base(owner, repo_name, base_sha, pr.head_ref_oid, pr.file_changes, github_pat)
return fetch_file_contents_with_base(
owner, repo_name, base_sha, pr.head_ref_oid, pr.file_changes, github_pat, pr_number=pr.number
)


def calculate_base_score(
Expand Down
Loading