@@ -171,6 +171,12 @@ def get_commit_info(commit):
171
171
print (f"start_commit: { args .start_commit } " )
172
172
print (f"end_commit: { args .end_commit } " )
173
173
174
+ # `get_commit_info` uses `requests.get()` to request info. via `api.github.com` without using token.
175
+ # If there are many new failed tests in a workflow run, this script may fail at some point with `KeyError` at
176
+ # `pr_number = pr_info_for_commit[0]["number"]` due to the rate limit.
177
+ # Let's cache the commit info. and reuse them whenever possible.
178
+ commit_info_cache = {}
179
+
174
180
if len ({args .test is None , args .file is None }) != 2 :
175
181
raise ValueError ("Exactly one argument `test` or `file` must be specified." )
176
182
@@ -191,7 +197,14 @@ def get_commit_info(commit):
191
197
for test in failed_tests :
192
198
commit = find_bad_commit (target_test = test , start_commit = args .start_commit , end_commit = args .end_commit )
193
199
info = {"test" : test , "commit" : commit }
194
- info .update (get_commit_info (commit ))
200
+
201
+ if commit in commit_info_cache :
202
+ commit_info = commit_info_cache [commit ]
203
+ else :
204
+ commit_info = get_commit_info (commit )
205
+ commit_info_cache [commit ] = commit_info
206
+
207
+ info .update (commit_info )
195
208
failed_tests_with_bad_commits .append (info )
196
209
197
210
# If no single-gpu test failures, remove the key
0 commit comments