Skip to content

Commit 3c40d85

Browse files
committed
download fix
1 parent 3eed4fc commit 3c40d85

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/inferencesh/sdk.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,16 @@ def _download_url(self) -> None:
5858
tmp_file = tempfile.NamedTemporaryFile(delete=False, suffix=suffix)
5959
self._tmp_path = tmp_file.name
6060

61+
# Set up request with user agent
62+
headers = {
63+
'User-Agent': 'inference.sh'
64+
}
65+
req = urllib.request.Request(original_url, headers=headers)
66+
6167
# Download the file
6268
print(f"Downloading URL: {original_url} to {self._tmp_path}")
63-
urllib.request.urlretrieve(original_url, self._tmp_path)
69+
with urllib.request.urlopen(req) as response, open(self._tmp_path, 'wb') as out_file:
70+
out_file.write(response.read())
6471
self.path = self._tmp_path
6572

6673
def __del__(self):

0 commit comments

Comments
 (0)