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

Commit c99ef9f

Browse files
authored
build(utils): allow to download in safetensors format (#174)
1 parent 3a821bf commit c99ef9f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

utils/download.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
This allows memory-constrained CI/CD runners to build container images
44
with large bundled models. See ../deployments/bundle/ for examples.
55
"""
6+
import os
67
import sys
78
import tempfile
89

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

15+
if os.getenv("TENSOR_FORMAT") == "safetensors":
16+
tensor_format = "*.safetensors"
17+
else:
18+
tensor_format = "*.bin"
19+
1420
with tempfile.TemporaryDirectory() as cache_dir:
1521
huggingface_hub.snapshot_download(
1622
repo_id=sys.argv[1],
@@ -19,5 +25,5 @@
1925
cache_dir=cache_dir,
2026
local_dir_use_symlinks=False,
2127
resume_download=True,
22-
allow_patterns=["*.bin", "*.json", "*.model", "*.py"],
28+
allow_patterns=[tensor_format, "*.json", "*.model", "*.py"],
2329
)

0 commit comments

Comments
 (0)