-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tools: Make external-link checker faster #67
base: main
Are you sure you want to change the base?
Tools: Make external-link checker faster #67
Conversation
…nd runs a head check before a get to prevent downloading huge files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, good thinking. Looks like an improvement.
issue: The timeit
functionality is unused. For timing in this pull request, use time.perf_counter()
instead.
@@ -278,11 +286,28 @@ def check_readme_link(url, rdme): | |||
|
|||
|
|||
def check_external_link(url): | |||
if "openai.com" in url or "science.org" in url: | |||
return [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (non-blocking): Maybe log a skip here?
response = requests.head(url, timeout=5, headers=headers) | ||
if response.status_code < 200 or response.status_code > 299: | ||
response = requests.get(url, timeout=5, headers=headers) | ||
except requests.RequestException: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: This will catch requests.RequestException
thrown from requests.get
on the line above.
This PR makes the external link checker in the doc sync tool faster.
Because of advanced crawling prevention, it now ignores openai.com and science.org urls.
Added some logging that shows the timing of URLs that take over a second to query.