Upload 5 files
Browse files- index.html +7 -6
- test_models_diagnostic.py +233 -0
index.html
CHANGED
|
@@ -17,6 +17,7 @@
|
|
| 17 |
<link rel="stylesheet" href="/static/css/main.css">
|
| 18 |
<link rel="stylesheet" href="/static/css/toast.css">
|
| 19 |
<script src="/static/js/trading-pairs-loader.js" defer></script>
|
|
|
|
| 20 |
<script src="/static/js/app.js" defer></script>
|
| 21 |
|
| 22 |
<!-- Favicon -->
|
|
@@ -613,26 +614,26 @@
|
|
| 613 |
<!-- Action Buttons -->
|
| 614 |
<div class="diagnostic-actions">
|
| 615 |
<button class="btn-primary" id="run-diagnostics-btn" onclick="runDiagnostic()">
|
| 616 |
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
| 617 |
<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon>
|
| 618 |
</svg>
|
| 619 |
-
|
| 620 |
</button>
|
| 621 |
<button class="btn-secondary" onclick="refreshDiagnosticStatus()">
|
| 622 |
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
| 623 |
<polyline points="23 4 23 10 17 10"></polyline>
|
| 624 |
<polyline points="1 20 1 14 7 14"></polyline>
|
| 625 |
<path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"></path>
|
| 626 |
</svg>
|
| 627 |
-
|
| 628 |
</button>
|
| 629 |
<button class="btn-secondary" onclick="downloadDiagnosticLog()">
|
| 630 |
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
| 631 |
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
|
| 632 |
<polyline points="7 10 12 15 17 10"></polyline>
|
| 633 |
<line x1="12" y1="15" x2="12" y2="3"></line>
|
| 634 |
</svg>
|
| 635 |
-
|
| 636 |
</button>
|
| 637 |
</div>
|
| 638 |
|
|
|
|
| 17 |
<link rel="stylesheet" href="/static/css/main.css">
|
| 18 |
<link rel="stylesheet" href="/static/css/toast.css">
|
| 19 |
<script src="/static/js/trading-pairs-loader.js" defer></script>
|
| 20 |
+
<script src="/static/js/toast.js" defer></script>
|
| 21 |
<script src="/static/js/app.js" defer></script>
|
| 22 |
|
| 23 |
<!-- Favicon -->
|
|
|
|
| 614 |
<!-- Action Buttons -->
|
| 615 |
<div class="diagnostic-actions">
|
| 616 |
<button class="btn-primary" id="run-diagnostics-btn" onclick="runDiagnostic()">
|
| 617 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 618 |
<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon>
|
| 619 |
</svg>
|
| 620 |
+
<span>βΆοΈ Run Full Diagnostic</span>
|
| 621 |
</button>
|
| 622 |
<button class="btn-secondary" onclick="refreshDiagnosticStatus()">
|
| 623 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 624 |
<polyline points="23 4 23 10 17 10"></polyline>
|
| 625 |
<polyline points="1 20 1 14 7 14"></polyline>
|
| 626 |
<path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"></path>
|
| 627 |
</svg>
|
| 628 |
+
<span>π Refresh Status</span>
|
| 629 |
</button>
|
| 630 |
<button class="btn-secondary" onclick="downloadDiagnosticLog()">
|
| 631 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
| 632 |
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
|
| 633 |
<polyline points="7 10 12 15 17 10"></polyline>
|
| 634 |
<line x1="12" y1="15" x2="12" y2="3"></line>
|
| 635 |
</svg>
|
| 636 |
+
<span>π₯ Download Log</span>
|
| 637 |
</button>
|
| 638 |
</div>
|
| 639 |
|
test_models_diagnostic.py
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Model Diagnostic Tool - Run this to debug why models aren't loading
|
| 4 |
+
Usage: python test_models.py
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import os
|
| 8 |
+
import sys
|
| 9 |
+
|
| 10 |
+
print("=" * 80)
|
| 11 |
+
print("π HUGGINGFACE MODEL DIAGNOSTIC TOOL")
|
| 12 |
+
print("=" * 80)
|
| 13 |
+
|
| 14 |
+
# Step 1: Check environment
|
| 15 |
+
print("\nπ Step 1: Environment Check")
|
| 16 |
+
print("-" * 80)
|
| 17 |
+
|
| 18 |
+
hf_token = os.getenv("HF_TOKEN") or os.getenv("HUGGINGFACE_TOKEN")
|
| 19 |
+
hf_mode = os.getenv("HF_MODE", "public").lower()
|
| 20 |
+
|
| 21 |
+
print(f"HF_MODE: {hf_mode}")
|
| 22 |
+
print(f"HF_TOKEN: {'β
Found ({} chars)'.format(len(hf_token)) if hf_token else 'β Not found'}")
|
| 23 |
+
print(f"Python version: {sys.version}")
|
| 24 |
+
|
| 25 |
+
# Step 2: Check transformers
|
| 26 |
+
print("\nπ¦ Step 2: Library Check")
|
| 27 |
+
print("-" * 80)
|
| 28 |
+
|
| 29 |
+
try:
|
| 30 |
+
import transformers
|
| 31 |
+
print(f"β
transformers: {transformers.__version__}")
|
| 32 |
+
TRANSFORMERS_OK = True
|
| 33 |
+
except ImportError as e:
|
| 34 |
+
print(f"β transformers: NOT INSTALLED")
|
| 35 |
+
print(f" Error: {e}")
|
| 36 |
+
print(f" Fix: pip install transformers torch")
|
| 37 |
+
TRANSFORMERS_OK = False
|
| 38 |
+
|
| 39 |
+
try:
|
| 40 |
+
import torch
|
| 41 |
+
print(f"β
torch: {torch.__version__}")
|
| 42 |
+
TORCH_OK = True
|
| 43 |
+
except ImportError as e:
|
| 44 |
+
print(f"β torch: NOT INSTALLED")
|
| 45 |
+
print(f" Error: {e}")
|
| 46 |
+
print(f" Fix: pip install torch")
|
| 47 |
+
TORCH_OK = False
|
| 48 |
+
|
| 49 |
+
try:
|
| 50 |
+
from huggingface_hub import HfApi
|
| 51 |
+
print(f"β
huggingface_hub: Available")
|
| 52 |
+
HUB_OK = True
|
| 53 |
+
except ImportError as e:
|
| 54 |
+
print(f"β huggingface_hub: NOT INSTALLED")
|
| 55 |
+
print(f" Error: {e}")
|
| 56 |
+
print(f" Fix: pip install huggingface-hub")
|
| 57 |
+
HUB_OK = False
|
| 58 |
+
|
| 59 |
+
# Step 3: Test HuggingFace Hub connection
|
| 60 |
+
print("\nπ Step 3: HuggingFace Hub Connection Test")
|
| 61 |
+
print("-" * 80)
|
| 62 |
+
|
| 63 |
+
if HUB_OK:
|
| 64 |
+
try:
|
| 65 |
+
from huggingface_hub import HfApi
|
| 66 |
+
api = HfApi()
|
| 67 |
+
|
| 68 |
+
# Test public access
|
| 69 |
+
print("Testing public access...")
|
| 70 |
+
model_info = api.model_info("bert-base-uncased")
|
| 71 |
+
print("β
Public access: OK")
|
| 72 |
+
|
| 73 |
+
# Test authenticated access if token available
|
| 74 |
+
if hf_token:
|
| 75 |
+
try:
|
| 76 |
+
api = HfApi(token=hf_token)
|
| 77 |
+
user_info = api.whoami()
|
| 78 |
+
print(f"β
Authenticated access: OK")
|
| 79 |
+
print(f" Logged in as: {user_info.get('name', 'unknown')}")
|
| 80 |
+
except Exception as e:
|
| 81 |
+
print(f"β Authenticated access: FAILED")
|
| 82 |
+
print(f" Error: {str(e)[:200]}")
|
| 83 |
+
else:
|
| 84 |
+
print("β οΈ No token - skipping auth test")
|
| 85 |
+
|
| 86 |
+
except Exception as e:
|
| 87 |
+
print(f"β Hub connection: FAILED")
|
| 88 |
+
print(f" Error: {str(e)[:200]}")
|
| 89 |
+
else:
|
| 90 |
+
print("βοΈ Skipping (huggingface_hub not available)")
|
| 91 |
+
|
| 92 |
+
# Step 4: Try loading a simple model
|
| 93 |
+
print("\nπ§ͺ Step 4: Test Model Loading")
|
| 94 |
+
print("-" * 80)
|
| 95 |
+
|
| 96 |
+
if TRANSFORMERS_OK:
|
| 97 |
+
from transformers import pipeline
|
| 98 |
+
|
| 99 |
+
test_models = [
|
| 100 |
+
("bert-base-uncased", "fill-mask", False), # Public, small
|
| 101 |
+
("ElKulako/cryptobert", "text-classification", True), # Private, needs auth
|
| 102 |
+
]
|
| 103 |
+
|
| 104 |
+
for model_id, task, needs_auth in test_models:
|
| 105 |
+
print(f"\nTesting: {model_id} ({task})")
|
| 106 |
+
print(f"Auth required: {needs_auth}")
|
| 107 |
+
|
| 108 |
+
try:
|
| 109 |
+
pipeline_kwargs = {"task": task, "model": model_id}
|
| 110 |
+
|
| 111 |
+
if needs_auth and hf_token:
|
| 112 |
+
pipeline_kwargs["token"] = hf_token
|
| 113 |
+
print(" Using authentication token...")
|
| 114 |
+
elif needs_auth and not hf_token:
|
| 115 |
+
print(" β οΈ Model needs auth but no token available")
|
| 116 |
+
print(" βοΈ Skipping this model")
|
| 117 |
+
continue
|
| 118 |
+
|
| 119 |
+
print(" Downloading/loading...")
|
| 120 |
+
pipe = pipeline(**pipeline_kwargs)
|
| 121 |
+
print(f" β
SUCCESS: Model loaded")
|
| 122 |
+
|
| 123 |
+
# Try a test inference
|
| 124 |
+
if task == "fill-mask":
|
| 125 |
+
result = pipe("Hello [MASK]")
|
| 126 |
+
print(f" Test inference: OK")
|
| 127 |
+
elif task == "text-classification":
|
| 128 |
+
result = pipe("Bitcoin is pumping")
|
| 129 |
+
print(f" Test inference: OK")
|
| 130 |
+
print(f" Result: {result}")
|
| 131 |
+
|
| 132 |
+
except Exception as e:
|
| 133 |
+
print(f" β FAILED: {type(e).__name__}")
|
| 134 |
+
print(f" Error: {str(e)[:300]}")
|
| 135 |
+
|
| 136 |
+
# Specific error hints
|
| 137 |
+
if "401" in str(e) or "unauthorized" in str(e).lower():
|
| 138 |
+
print(f" π‘ Hint: This model requires authentication")
|
| 139 |
+
print(f" Set HF_TOKEN environment variable")
|
| 140 |
+
elif "404" in str(e) or "not found" in str(e).lower():
|
| 141 |
+
print(f" π‘ Hint: Model not found on HuggingFace Hub")
|
| 142 |
+
print(f" Check model ID: {model_id}")
|
| 143 |
+
elif "403" in str(e) or "forbidden" in str(e).lower():
|
| 144 |
+
print(f" π‘ Hint: Access forbidden - check permissions")
|
| 145 |
+
else:
|
| 146 |
+
print("βοΈ Skipping (transformers not available)")
|
| 147 |
+
|
| 148 |
+
# Step 5: Check ai_models.py
|
| 149 |
+
print("\nπ Step 5: Check ai_models.py Integration")
|
| 150 |
+
print("-" * 80)
|
| 151 |
+
|
| 152 |
+
try:
|
| 153 |
+
import ai_models
|
| 154 |
+
print("β
ai_models.py: Importable")
|
| 155 |
+
|
| 156 |
+
# Check registry status
|
| 157 |
+
status = ai_models.registry_status()
|
| 158 |
+
print(f" HF_MODE: {status.get('hf_mode')}")
|
| 159 |
+
print(f" Initialized: {status.get('initialized')}")
|
| 160 |
+
print(f" Transformers available: {status.get('transformers_available')}")
|
| 161 |
+
print(f" Models loaded: {status.get('pipelines_loaded')}")
|
| 162 |
+
print(f" Models failed: {status.get('pipelines_failed')}")
|
| 163 |
+
|
| 164 |
+
if status.get('failed_models'):
|
| 165 |
+
print(f"\n Failed models:")
|
| 166 |
+
for key in status.get('failed_models', [])[:5]:
|
| 167 |
+
print(f" - {key}")
|
| 168 |
+
|
| 169 |
+
# Try to initialize
|
| 170 |
+
print("\n Attempting initialize_models()...")
|
| 171 |
+
init_result = ai_models.initialize_models()
|
| 172 |
+
print(f" Result: {init_result.get('status')}")
|
| 173 |
+
if init_result.get('note'):
|
| 174 |
+
print(f" Note: {init_result.get('note')}")
|
| 175 |
+
|
| 176 |
+
# Try to load one model
|
| 177 |
+
print("\n Attempting to load crypto_sent_kk08...")
|
| 178 |
+
try:
|
| 179 |
+
pipe = ai_models._registry.get_pipeline("crypto_sent_kk08")
|
| 180 |
+
print(f" β
Model loaded successfully!")
|
| 181 |
+
|
| 182 |
+
# Test inference
|
| 183 |
+
result = pipe("Bitcoin price surging")
|
| 184 |
+
print(f" Test inference: {result}")
|
| 185 |
+
|
| 186 |
+
except ai_models.ModelNotAvailable as e:
|
| 187 |
+
print(f" β Model not available: {str(e)[:200]}")
|
| 188 |
+
except Exception as e:
|
| 189 |
+
print(f" β Error: {type(e).__name__}: {str(e)[:200]}")
|
| 190 |
+
|
| 191 |
+
except ImportError as e:
|
| 192 |
+
print(f"β ai_models.py: Cannot import")
|
| 193 |
+
print(f" Error: {e}")
|
| 194 |
+
print(f" Make sure ai_models.py is in the same directory")
|
| 195 |
+
|
| 196 |
+
# Summary
|
| 197 |
+
print("\n" + "=" * 80)
|
| 198 |
+
print("π DIAGNOSTIC SUMMARY")
|
| 199 |
+
print("=" * 80)
|
| 200 |
+
|
| 201 |
+
issues = []
|
| 202 |
+
fixes = []
|
| 203 |
+
|
| 204 |
+
if not TRANSFORMERS_OK:
|
| 205 |
+
issues.append("β transformers library not installed")
|
| 206 |
+
fixes.append("pip install transformers torch")
|
| 207 |
+
|
| 208 |
+
if not TORCH_OK:
|
| 209 |
+
issues.append("β torch library not installed")
|
| 210 |
+
fixes.append("pip install torch")
|
| 211 |
+
|
| 212 |
+
if not hf_token and hf_mode == "auth":
|
| 213 |
+
issues.append("β HF_TOKEN not set but HF_MODE=auth")
|
| 214 |
+
fixes.append("Set HF_TOKEN environment variable or change HF_MODE to 'public'")
|
| 215 |
+
|
| 216 |
+
if not issues:
|
| 217 |
+
print("β
No critical issues found")
|
| 218 |
+
print("\nIf models still aren't loading:")
|
| 219 |
+
print("1. Check the logs above for specific model errors")
|
| 220 |
+
print("2. Verify internet connection to huggingface.co")
|
| 221 |
+
print("3. Try running: python test_models.py > diagnostic.log 2>&1")
|
| 222 |
+
else:
|
| 223 |
+
print("β Issues found:")
|
| 224 |
+
for issue in issues:
|
| 225 |
+
print(f" {issue}")
|
| 226 |
+
|
| 227 |
+
print("\nπ§ Suggested fixes:")
|
| 228 |
+
for fix in fixes:
|
| 229 |
+
print(f" β’ {fix}")
|
| 230 |
+
|
| 231 |
+
print("\n" + "=" * 80)
|
| 232 |
+
print("β
Diagnostic complete")
|
| 233 |
+
print("=" * 80)
|