Skip to content
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

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

codeallthethingz
Copy link
Contributor

This PR makes the external link checker in the doc sync tool faster.

  • sets threads to 10
  • runs a head request check before a get to prevent downloading huge files

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.

@codeallthethingz codeallthethingz added infrastructure Changes to infrastructure triaged This issue or pull request was triaged labels Nov 25, 2024
Copy link
Contributor

@tristanls tristanls left a 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 []
Copy link
Contributor

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:
Copy link
Contributor

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.

@codeallthethingz codeallthethingz marked this pull request as draft December 5, 2024 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Changes to infrastructure triaged This issue or pull request was triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants