File size: 1,130 Bytes
cc126b6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | """Pull cloud-computed artifacts from HF Hub to local machine.
Run this locally after cloud jobs finish. Pulls only small files:
- embeddings parquet (~30MB)
- enriched parquet with full text (~200MB)
Usage:
python scripts/cloud/pull_from_hub.py
"""
import os
from pathlib import Path
from huggingface_hub import hf_hub_download
from dotenv import load_dotenv
load_dotenv(".env")
token = os.environ.get("HF_TOKEN")
REPO = "midah/patent-wireframes"
ARTIFACTS = [
("embeddings_2022_vitl14.parquet", "data/embeddings/embeddings_2022_vitl14.parquet"),
("enriched_2022_full.parquet", "data/enriched/enriched_2022_full.parquet"),
]
for remote_name, local_path in ARTIFACTS:
dest = Path(local_path)
dest.parent.mkdir(parents=True, exist_ok=True)
try:
path = hf_hub_download(
repo_id=REPO, filename=remote_name,
repo_type="dataset", token=token, local_dir=str(dest.parent),
)
size = Path(path).stat().st_size / 1e6
print(f"✓ {remote_name} → {local_path} ({size:.1f}MB)")
except Exception as e:
print(f"✗ {remote_name}: {e}")
|