Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
build(utils): allow to download in safetensors format (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
fardeon authored Apr 21, 2023
1 parent 3a821bf commit c99ef9f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion utils/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This allows memory-constrained CI/CD runners to build container images
with large bundled models. See ../deployments/bundle/ for examples.
"""
import os
import sys
import tempfile

Expand All @@ -11,6 +12,11 @@
if len(sys.argv) < 3:
sys.exit("usage: python download.py REPO_ID LOCAL_DIR [REVISION]")

if os.getenv("TENSOR_FORMAT") == "safetensors":
tensor_format = "*.safetensors"
else:
tensor_format = "*.bin"

with tempfile.TemporaryDirectory() as cache_dir:
huggingface_hub.snapshot_download(
repo_id=sys.argv[1],
Expand All @@ -19,5 +25,5 @@
cache_dir=cache_dir,
local_dir_use_symlinks=False,
resume_download=True,
allow_patterns=["*.bin", "*.json", "*.model", "*.py"],
allow_patterns=[tensor_format, "*.json", "*.model", "*.py"],
)

0 comments on commit c99ef9f

Please sign in to comment.