mirror of
https://github.com/karpathy/nanochat.git
synced 2025-12-06 12:22:18 +00:00
Merge 6ef9f77789 into bc1fca39f3
This commit is contained in:
commit
cc4445b533
|
|
@ -438,10 +438,12 @@ def enwik8_path():
|
||||||
enwik8_local_path_zip = os.path.join(base_dir, "enwik8.zip")
|
enwik8_local_path_zip = os.path.join(base_dir, "enwik8.zip")
|
||||||
if not os.path.exists(enwik8_local_path):
|
if not os.path.exists(enwik8_local_path):
|
||||||
print(f"Downloading enwik8 to {enwik8_local_path_zip}")
|
print(f"Downloading enwik8 to {enwik8_local_path_zip}")
|
||||||
import requests
|
import urllib.request, urllib.error
|
||||||
response = requests.get(enwik8_url)
|
try:
|
||||||
with open(enwik8_local_path_zip, "wb") as f:
|
with urllib.request.urlopen(enwik8_url, timeout=30) as resp, open(enwik8_local_path_zip, "wb") as f:
|
||||||
f.write(response.content)
|
f.write(resp.read())
|
||||||
|
except (urllib.error.URLError, urllib.error.HTTPError) as e:
|
||||||
|
pytest.skip(f"Network unavailable or download failed: {e}")
|
||||||
with zipfile.ZipFile(enwik8_local_path_zip, "r") as zip_ref:
|
with zipfile.ZipFile(enwik8_local_path_zip, "r") as zip_ref:
|
||||||
zip_ref.extractall(base_dir)
|
zip_ref.extractall(base_dir)
|
||||||
print(f"Unzipped enwik8 to {enwik8_local_path}")
|
print(f"Unzipped enwik8 to {enwik8_local_path}")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user