Content-Length: 318182 | pFad | http://github.com/aws-mwaa/upstream-to-airflow/commit/43e5959f8d68a28940262aeac3abefe2907cf120

04 [v3-0-test] Use GitHub API to download constraint files and avoid rat… · aws-mwaa/upstream-to-airflow@43e5959 · GitHub
Skip to content

Commit 43e5959

Browse files
amoghrajeshYour Name
authored and
Your Name
committed
[v3-0-test] Use GitHub API to download constraint files and avoid rate limiting (apache#50716)
(cherry picked from commit 35a4ced) Co-authored-by: Amogh Desai <amoghrajesh1999@gmail.com>
1 parent 377160c commit 43e5959

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

dev/breeze/src/airflow_breeze/utils/github.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def download_file_from_github(
4444
tag: str, path: str, output_file: Path, github_token: str | None = None, timeout: int = 60
4545
) -> bool:
4646
"""
47-
Downloads a file from GitHub repository of Apache Airflow
47+
Downloads a file from the GitHub repository of Apache Airflow using the GitHub API.
4848
4949
:param tag: tag to download from
5050
:param path: path of the file relative to the repository root
@@ -55,21 +55,21 @@ def download_file_from_github(
5555
"""
5656
import requests
5757

58-
url = f"https://raw.githubusercontent.com/apache/airflow/{tag}/{path}"
58+
url = f"https://api.github.com/repos/apache/airflow/contents/{path}?ref={tag}"
5959
get_console().print(f"[info]Downloading {url} to {output_file}")
6060
if not get_dry_run():
61+
headers = {"Accept": "application/vnd.github.v3.raw"}
62+
if github_token:
63+
headers["Authorization"] = f"Bearer {github_token}"
64+
headers["X-GitHub-Api-Version"] = "2022-11-28"
6165
try:
62-
# add github token to the request if provided
63-
headers = {}
64-
if github_token:
65-
headers["Authorization"] = f"Bearer {github_token}"
66-
headers["X-GitHub-Api-Version"] = "2022-11-28"
6766
response = requests.get(url, headers=headers, timeout=timeout)
6867
if response.status_code == 403:
6968
get_console().print(
70-
f"[error]The {url} is not accessible.This may be caused by either of:\n"
71-
f" 1. network issues or VPN settings\n"
72-
f" 2. Github rate limit"
69+
f"[error]Access denied to {url}. This may be caused by:\n"
70+
f" 1. Network issues or VPN settings\n"
71+
f" 2. GitHub API rate limiting\n"
72+
f" 3. Invalid or missing GitHub token"
7373
)
7474
return False
7575
if response.status_code == 404:

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/aws-mwaa/upstream-to-airflow/commit/43e5959f8d68a28940262aeac3abefe2907cf120

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy