Skip to content

Commit

Permalink
Fix httpx usage
Browse files Browse the repository at this point in the history
Follow redirects when downloading from GitHub via httpx.
Fixes issue #686 [1].

[1]: #686

Reported-by: Antonio Petricca <[email protected]>
  • Loading branch information
claui committed Jul 20, 2023
1 parent 13c771b commit 3a5735d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
42 changes: 25 additions & 17 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ include = ["LICENSE", "spleeter/resources/*.json"]
[tool.poetry.dependencies]
python = ">=3.7.1,<3.11"
ffmpeg-python = "^0.2.0"
httpx = {extras = ["http2"], version = "^0.19.0"}
httpx = {extras = ["http2"], version = "^0.23.1"}
typer = "^0.3.2"
musdb = {version = "^0.4.0", optional = true}
museval = {version = "^0.4.0", optional = true}
Expand Down
4 changes: 2 additions & 2 deletions spleeter/model/provider/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def checksum(self, name: str) -> str:
self.CHECKSUM_INDEX,
)
)
response: httpx.Response = httpx.get(url)
response: httpx.Response = httpx.get(url, follow_redirects=True)
response.raise_for_status()
index: Dict = response.json()
if name not in index:
Expand All @@ -144,7 +144,7 @@ def download(self, name: str, path: str) -> None:
url = f"{url}.tar.gz"
logger.info(f"Downloading model archive {url}")
with httpx.Client(http2=True) as client:
with client.stream("GET", url) as response:
with client.stream("GET", url, follow_redirects=True) as response:
response.raise_for_status()
archive = NamedTemporaryFile(delete=False)
try:
Expand Down

0 comments on commit 3a5735d

Please sign in to comment.