fix: preflight Hugging Face GGUF disk space
This commit is contained in:
@@ -1539,6 +1539,18 @@ def _run_huggingface_download(job_id: str, repo_id: str, filename: str) -> None:
|
|||||||
download_files = list(file_info.get("filenames") or [filename])
|
download_files = list(file_info.get("filenames") or [filename])
|
||||||
completed = 0
|
completed = 0
|
||||||
total = expected
|
total = expected
|
||||||
|
if not total:
|
||||||
|
for remote_filename in download_files:
|
||||||
|
head_url = f"https://huggingface.co/{repo_id}/resolve/main/{remote_filename}?download=true"
|
||||||
|
try:
|
||||||
|
head_request = Request(head_url, method="HEAD", headers={"User-Agent": "Hermes-Ollama-Models/1.7.4"})
|
||||||
|
with urlopen(head_request, timeout=30) as head_response:
|
||||||
|
total += int(head_response.headers.get("Content-Length") or 0)
|
||||||
|
except (HTTPError, URLError, OSError, ValueError):
|
||||||
|
continue
|
||||||
|
free_bytes = shutil.disk_usage(_home()).free
|
||||||
|
if total and free_bytes < total + 1024 ** 3:
|
||||||
|
raise RuntimeError("Insufficient free disk space for the complete Hugging Face GGUF download")
|
||||||
for remote_filename in download_files:
|
for remote_filename in download_files:
|
||||||
destination = destination_root / remote_filename
|
destination = destination_root / remote_filename
|
||||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user