e3c8979e8d
- cmd/fn/doctor.go - cmd/fn/main.go - cpp/apps/primitives_gallery/playground/tables/CMakeLists.txt - cpp/apps/primitives_gallery/playground/tables/data_table.cpp - cpp/apps/primitives_gallery/playground/tables/data_table_logic.cpp - cpp/apps/primitives_gallery/playground/tables/data_table_logic.h - cpp/apps/primitives_gallery/playground/tables/self_test.cpp - cpp/apps/primitives_gallery/playground/tables/tql.cpp - cpp/apps/primitives_gallery/playground/tables/viz.cpp - cpp/apps/primitives_gallery/playground/tables/viz.h - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3.8 KiB
3.8 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | |||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| hf_snapshot_download | function | py | ml | 1.0.0 | impure | def hf_snapshot_download(repo_id: str, allow_patterns: list[str] | None = None, ignore_patterns: list[str] | None = None, local_dir: str | None = None, token: str | None = None) -> str | Descarga un snapshot de un repo HuggingFace Hub (completo o filtrado por patrones glob). Wrapper de huggingface_hub.snapshot_download con ImportError descriptivo. Soporta repos privados/gated via token. Retorna path local del snapshot. |
|
false | error_go_core |
|
|
string: path absoluto al directorio local donde quedo almacenado el snapshot | true |
|
python/functions/ml/tests/test_hf_snapshot_download.py | python/functions/ml/hf_snapshot_download.py |
Ejemplo
from ml.hf_snapshot_download import hf_snapshot_download
# Descargar solo safetensors y JSONs de SD v1.5 (evita el .bin de 4 GB)
path = hf_snapshot_download(
repo_id="runwayml/stable-diffusion-v1-5",
allow_patterns=["*.safetensors", "*.json", "*.txt"],
ignore_patterns=["*.bin"],
local_dir=".local/models/sd-v1-5",
)
# path = "/home/lucas/fn_registry/.local/models/sd-v1-5"
# Descargar un modelo gated (Llama) con token
path = hf_snapshot_download(
repo_id="meta-llama/Llama-2-7b-hf",
ignore_patterns=["*.bin"],
local_dir=".local/models/llama-2-7b",
token="hf_xxxxxxxxxxxxxxxxxxxxxxxx",
)
# Descargar al cache global (sin local_dir)
path = hf_snapshot_download("BAAI/bge-m3")
# path = "/home/lucas/.cache/huggingface/hub/models--BAAI--bge-m3/snapshots/..."
Notas
- El wrapper es minimo: no reimplementa logica de descarga, solo asegura que
huggingface_hubno sea requerido en tiempo de indexacion del registry. snapshot_downloades idempotente: si el snapshot ya existe en el cache/local_dir con los mismos hashes, no vuelve a descargar.allow_patternsyignore_patternsusan la semantica defnmatch. Tienen precedencia: si un archivo coincide con ambos,ignore_patternsgana.- Para repos grandes (>10 GB), conviene usar
ignore_patterns=["*.bin"]si el repo ofrece safetensors (formato mas seguro, sin pickle, y soporta mmap). - El token puede ponerse tambien en
~/.cache/huggingface/tokenviahuggingface-cli loginpara no pasarlo inline. - impure: hace I/O de red, escribe en disco, depende de disponibilidad del Hub.