File size: 3,124 Bytes
38b4eff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python3
"""
NeuralAI ← Hugging Face Pull Script
Downloads model checkpoints, training data, and configs from the Hub.
"""

import os
import sys
from huggingface_hub import HfApi, snapshot_download

REPO_ID = "Subject-Emu-5259/NeuralAI"
LOCAL_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

def main():
    api = HfApi()
    
    user = api.whoami(token=True)
    print(f"🔗 Connected as: {user['name']}")
    print(f"📦 Repo: {REPO_ID}")
    
    action = sys.argv[1] if len(sys.argv) > 1 else "all"
    
    if action == "model" or action == "all":
        print("\n📥 Pulling model adapter...")
        model_files = [
            "adapter_config.json",
            "adapter_model.safetensors",
            "chat_template.jinja",
            "tokenizer.json",
            "tokenizer_config.json",
            "training_log.json",
        ]
        for f in model_files:
            try:
                api.hf_hub_download(
                    repo_id=REPO_ID,
                    filename=f,
                    local_dir=os.path.join(LOCAL_DIR, "checkpoints", "v2_model"),
                    local_dir_use_symlinks=False,
                    token=True
                )
                print(f"  ✅ {f}")
            except Exception as e:
                print(f"  ⏭️  {f} (not found on Hub)")
    
    if action == "data" or action == "all":
        print("\n📥 Pulling training data...")
        try:
            files = api.list_repo_files(REPO_ID, repo_type="model", token=True)
            data_files = [f for f in files if f.startswith("data/")]
            for f in data_files:
                local_path = os.path.join(LOCAL_DIR, f)
                os.makedirs(os.path.dirname(local_path), exist_ok=True)
                api.hf_hub_download(
                    repo_id=REPO_ID,
                    filename=f,
                    local_dir=LOCAL_DIR,
                    local_dir_use_symlinks=False,
                    token=True
                )
                print(f"  ✅ {f}")
        except Exception as e:
            print(f"  ❌ Error: {e}")
    
    if action == "scripts" or action == "all":
        print("\n📥 Pulling training scripts...")
        try:
            files = api.list_repo_files(REPO_ID, repo_type="model", token=True)
            for prefix in ["training/", "services/", "tools/"]:
                for f in [x for x in files if x.startswith(prefix)]:
                    local_path = os.path.join(LOCAL_DIR, f)
                    os.makedirs(os.path.dirname(local_path), exist_ok=True)
                    api.hf_hub_download(
                        repo_id=REPO_ID,
                        filename=f,
                        local_dir=LOCAL_DIR,
                        local_dir_use_symlinks=False,
                        token=True
                    )
                    print(f"  ✅ {f}")
        except Exception as e:
            print(f"  ❌ Error: {e}")
    
    print(f"\n{'='*50}")
    print(f"✅ Pull complete! Files synced to {LOCAL_DIR}")
    print(f"{'='*50}")

if __name__ == "__main__":
    main()