Skip to content

Commit 408be8a

Browse files
committed
[CI] Fix rounding when determining number of API batches to query
When querying the GitHub API, we get a runtime error if the batch size is a multiple of the total number of commits. One extra batch is queried for 0 commits, which then raises an exception when trying to access the results. This change corrects the number of batches to query for in those cases.
1 parent c5806e4 commit 408be8a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

premerge/ops-container/process_llvm_commits.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import dataclasses
22
import datetime
33
import logging
4+
import math
45
import os
56
import git
67
from google.cloud import bigquery
@@ -144,7 +145,7 @@ def query_for_reviews(
144145
}
145146
}
146147
"""
147-
num_batches = len(commit_subqueries) // GITHUB_API_BATCH_SIZE + 1
148+
num_batches = math.ceil(len(commit_subqueries) / GITHUB_API_BATCH_SIZE)
148149
logging.info("Querying GitHub GraphQL API in %d batches", num_batches)
149150
for i in range(num_batches):
150151
subquery_batch = commit_subqueries[

0 commit comments

Comments
 (0)