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

build(utils): allow to download in safetensors format #174

Merged
merged 1 commit into from
Apr 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"],
)