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