| """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}") |
|
|