Fix bug where a github api failure would prevent the label check from failing (#95098)

Fix bug where a github api failure would prevent the check from failing even if we already saw that labels were needed.

Also adds more debugging info to the rate limit exceeded error since it's weird to see an error claiming the rate limit has exceeded when the "Used" amount is way below the limit.  I suspect these happen when the request arrived just before the rate reset time, but the response was generated right after the reset time, hence the apparently tiny "used" amounts

Example run where the check should have failed, but passed instead:
https://github.com/pytorch/pytorch/actions/runs/4200205209/jobs/7285979824
Pull Request resolved: https://github.com/pytorch/pytorch/pull/95098
Approved by: https://github.com/huydhn
This commit is contained in:
Zain Rizvi
2023-02-21 18:42:12 +00:00
committed by PyTorch MergeBot
parent 311b20aae1
commit da98053c6d
2 changed files with 9 additions and 2 deletions

View File

@ -456,7 +456,11 @@ def _fetch_url(url: str, *,
return reader(conn)
except HTTPError as err:
if err.code == 403 and all(key in err.headers for key in ['X-RateLimit-Limit', 'X-RateLimit-Used']):
print(f"Rate limit exceeded: {err.headers['X-RateLimit-Used']}/{err.headers['X-RateLimit-Limit']}")
print(f"""Rate limit exceeded:
Used: {err.headers['X-RateLimit-Used']}
Limit: {err.headers['X-RateLimit-Limit']}
Remaining: {err.headers['X-RateLimit-Remaining']}
Resets at: {err.headers['x-RateLimit-Reset']}""")
raise
def _fetch_json_any(