alibayram commited on
Commit
abcde8f
·
1 Parent(s): ec76a6d

Enhance logging and error handling in the Gradio app, improve model existence checks with detailed logging, and add connectivity testing feature in the submission UI. Update data manager for better model validation and submission processes.

Browse files
Files changed (7) hide show
  1. HF_SPACES_DEBUG.md +111 -0
  2. app.py +56 -27
  3. data_manager.py +40 -50
  4. debug_hf_spaces.py +203 -0
  5. model_validator.py +35 -18
  6. test_hf_spaces.py +118 -0
  7. ui_submit_model.py +122 -76
HF_SPACES_DEBUG.md ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hugging Face Spaces Debugging Guide
2
+
3
+ ## Issue: Validation Button Not Working
4
+
5
+ If the validation button is not responding when deployed to Hugging Face Spaces, follow these debugging steps:
6
+
7
+ ### 1. Run the Debug Script
8
+
9
+ First, run the comprehensive debugging script to identify the issue:
10
+
11
+ ```bash
12
+ python debug_hf_spaces.py
13
+ ```
14
+
15
+ This will create a `debug.log` file with detailed information about:
16
+
17
+ - Environment information
18
+ - Network connectivity
19
+ - Module imports
20
+ - Model validator functionality
21
+ - Data manager functionality
22
+
23
+ ### 2. Check Common Issues
24
+
25
+ #### Network Connectivity
26
+
27
+ Hugging Face Spaces might have different network policies. The debug script tests:
28
+
29
+ - Basic HTTP requests
30
+ - Ollama.com connectivity
31
+ - Hugging Face Hub connectivity
32
+
33
+ #### Timeout Issues
34
+
35
+ The validation process now includes:
36
+
37
+ - 30-second timeout for Ollama requests
38
+ - Retry logic with exponential backoff
39
+ - Fallback mechanism for network failures
40
+
41
+ #### Import Issues
42
+
43
+ Check if all modules are importing correctly:
44
+
45
+ - `model_validator`
46
+ - `data_manager`
47
+ - `api_service`
48
+ - UI modules
49
+
50
+ ### 3. Fallback Mechanism
51
+
52
+ If validation fails due to network issues, the system now provides a fallback:
53
+
54
+ - Shows a warning message
55
+ - Still allows model submission
56
+ - User can proceed with manual verification
57
+
58
+ ### 4. Manual Testing
59
+
60
+ You can test individual components:
61
+
62
+ ```bash
63
+ # Test basic connectivity
64
+ python -c "import requests; print(requests.get('https://ollama.com').status_code)"
65
+
66
+ # Test model validator
67
+ python -c "from model_validator import model_validator; print(model_validator.validate_ollama_model('llama2', '7b'))"
68
+
69
+ # Test data manager
70
+ python -c "from data_manager import data_manager; print(data_manager.check_model_exists('llama2', '7b'))"
71
+ ```
72
+
73
+ ### 5. Environment Variables
74
+
75
+ Check if these environment variables are set in your Hugging Face Space:
76
+
77
+ - `HF_TOKEN` (if needed for dataset access)
78
+ - `API_BASE_URL` (for model submission)
79
+
80
+ ### 6. Logs
81
+
82
+ Check the application logs in Hugging Face Spaces:
83
+
84
+ - Look for error messages
85
+ - Check for timeout errors
86
+ - Verify import statements
87
+
88
+ ### 7. Quick Fixes
89
+
90
+ If the issue persists:
91
+
92
+ 1. **Increase timeouts**: The system now uses 30-second timeouts
93
+ 2. **Use fallback mode**: The validation will show a warning but allow submission
94
+ 3. **Check network policies**: Ensure Ollama.com is accessible from Hugging Face Spaces
95
+
96
+ ### 8. Contact Support
97
+
98
+ If the issue continues, provide:
99
+
100
+ - The output from `debug_hf_spaces.py`
101
+ - The contents of `debug.log`
102
+ - Any error messages from Hugging Face Spaces logs
103
+
104
+ ## Files Modified for HF Spaces Compatibility
105
+
106
+ 1. **`model_validator.py`**: Added retry logic and increased timeouts
107
+ 2. **`ui_submit_model.py`**: Added fallback mechanism and better error handling
108
+ 3. **`data_manager.py`**: Improved error handling for dataset loading
109
+ 4. **`app.py`**: Added comprehensive logging and error handling
110
+ 5. **`debug_hf_spaces.py`**: Comprehensive debugging script
111
+ 6. **`test_hf_spaces.py`**: Basic functionality tests
app.py CHANGED
@@ -1,50 +1,79 @@
1
  import logging
2
  import sys
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  from apscheduler.schedulers.background import BackgroundScheduler
5
 
6
- from config import CONFIG
7
  from data_manager import data_manager
8
- from ui_main import create_clean_app
9
 
10
- logging.basicConfig(level=logging.INFO)
11
- logger = logging.getLogger(__name__)
12
 
13
  def main():
 
14
  try:
15
- # Zamanlayıcıyı başlat
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  scheduler = BackgroundScheduler()
17
  scheduler.add_job(
18
- data_manager.refresh_datasets,
19
  'interval',
20
- minutes=CONFIG["dataset"].refresh_interval // 60,
21
- id='dataset_refresh',
22
- replace_existing=True
23
  )
24
  scheduler.start()
25
- logger.info("Zamanlayıcı başlatıldı")
26
-
27
- # Uygulamayı oluştur ve başlat
28
- app = create_clean_app()
29
 
30
- logger.info("Uygulama başlatılıyor...")
 
31
  app.launch(
32
- server_name=CONFIG["app"].server_name,
33
- server_port=CONFIG["app"].server_port,
34
- share=CONFIG["app"].share,
35
- debug=CONFIG["app"].debug,
36
- show_error=CONFIG["app"].show_error
37
  )
38
 
39
- except KeyboardInterrupt:
40
- logger.info("Kullanıcı tarafından durduruldu")
41
  except Exception as e:
42
- logger.error(f"Uygulama başlatma hatası: {e}")
43
- sys.exit(1)
44
- finally:
45
- if 'scheduler' in locals():
46
- scheduler.shutdown()
47
- logger.info("Zamanlayıcı durduruldu")
48
 
49
  if __name__ == "__main__":
50
  main()
 
1
  import logging
2
  import sys
3
+ from pathlib import Path
4
+
5
+ # Set up logging
6
+ logging.basicConfig(
7
+ level=logging.INFO,
8
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
9
+ handlers=[
10
+ logging.StreamHandler(sys.stdout),
11
+ logging.FileHandler('app.log')
12
+ ]
13
+ )
14
+ logger = logging.getLogger(__name__)
15
+
16
+ try:
17
+ import gradio as gr
18
+
19
+ from config import CONFIG
20
+ from data_manager import DataManager
21
+ from ui_evaluation_requests import add_evaluation_requests_tab
22
+ from ui_leaderboard import add_leaderboard_tab
23
+ from ui_main import create_clean_app
24
+ from ui_model_responses import add_model_responses_tab
25
+ from ui_model_section_scores import add_model_section_scores_tab
26
+ from ui_submit_model import add_submit_model_tab
27
+
28
+ logger.info("All imports successful")
29
+ except Exception as e:
30
+ logger.error(f"Import error: {e}")
31
+ raise
32
 
33
  from apscheduler.schedulers.background import BackgroundScheduler
34
 
 
35
  from data_manager import data_manager
 
36
 
 
 
37
 
38
  def main():
39
+ """Ana uygulama fonksiyonu"""
40
  try:
41
+ logger.info("Starting Turkish MMLU Leaderboard application...")
42
+
43
+ # Initialize data manager
44
+ logger.info("Initializing data manager...")
45
+ data_manager_instance = DataManager()
46
+ logger.info("Data manager initialized successfully")
47
+
48
+ # Create the main interface
49
+ logger.info("Creating main interface...")
50
+ app = create_clean_app()
51
+ logger.info("Main interface created successfully")
52
+
53
+ # Start the scheduler for data refresh
54
+ logger.info("Starting background scheduler...")
55
  scheduler = BackgroundScheduler()
56
  scheduler.add_job(
57
+ data_manager_instance.refresh_datasets,
58
  'interval',
59
+ seconds=CONFIG["dataset"].refresh_interval,
60
+ id='refresh_datasets'
 
61
  )
62
  scheduler.start()
63
+ logger.info("Background scheduler started successfully")
 
 
 
64
 
65
+ # Launch the app
66
+ logger.info("Launching Gradio app...")
67
  app.launch(
68
+ server_name="0.0.0.0",
69
+ server_port=7860,
70
+ share=False,
71
+ debug=True
 
72
  )
73
 
 
 
74
  except Exception as e:
75
+ logger.error(f"Application startup failed: {e}")
76
+ raise
 
 
 
 
77
 
78
  if __name__ == "__main__":
79
  main()
data_manager.py CHANGED
@@ -219,64 +219,54 @@ class DataManager:
219
  logger.error(f"Veri özeti alma hatası: {e}")
220
  return {"hata": str(e), "mesaj": "Veri özeti alınamadı"}
221
 
222
- def check_model_exists(self, model_name: str, version: str) -> Dict:
223
- """Check if a model already exists in the leaderboard dataset (model column is model:version)."""
224
  try:
 
 
225
  df = self.leaderboard_data
226
  if df.empty:
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  return {
228
- 'exists': False,
229
- 'message': 'Liderlik tablosu verisi bulunamadı'
230
- }
231
- model_name_lower = model_name.lower().strip()
232
- version_lower = version.lower().strip()
233
- # Split model column into name/version
234
- def split_model(m):
235
- parts = str(m).split(":", 1)
236
- if len(parts) == 2:
237
- return parts[0].strip().lower(), parts[1].strip().lower()
238
- return parts[0].strip().lower(), ''
239
- # Find exact match
240
- matches = df['model'].apply(lambda m: split_model(m) == (model_name_lower, version_lower))
241
- if matches.any():
242
- model_row = df[matches].iloc[0]
243
- return {
244
- 'exists': True,
245
- 'model_data': model_row.to_dict(),
246
- 'status': 'completed',
247
- 'basari': model_row.get('basari', 0),
248
- 'progress': 1.0,
249
- 'message': f"Model {model_name}:{version} zaten liderlik tablosunda mevcut"
250
- }
251
- # Find similar models (same name, any version)
252
- similar_mask = df['model'].apply(lambda m: split_model(m)[0] == model_name_lower)
253
- similar_models = df[similar_mask]
254
- if not similar_models.empty:
255
- similar_info = []
256
- for _, row in similar_models.iterrows():
257
- _, v = split_model(row['model'])
258
- similar_info.append({
259
- 'version': v,
260
- 'status': 'completed',
261
- 'basari': row.get('basari', 0),
262
- 'progress': 1.0
263
- })
264
- return {
265
- 'exists': False,
266
- 'similar_models': similar_info,
267
- 'message': f"Model {model_name} bulundu, farklı versiyonlar mevcut"
268
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  return {
270
- 'exists': False,
271
- 'message': f"Model {model_name}:{version} liderlik tablosunda bulunamadı"
272
  }
 
273
  except Exception as e:
274
- logger.error(f"Model kontrol hatası: {e}")
275
- return {
276
- 'exists': False,
277
- 'error': str(e),
278
- 'message': f"Model kontrolü sırasında hata oluştu: {str(e)}"
279
- }
280
 
281
  def clear_cache(self):
282
  """Tüm önbelleğe alınan verileri ve zaman damgalarını temizle."""
 
219
  logger.error(f"Veri özeti alma hatası: {e}")
220
  return {"hata": str(e), "mesaj": "Veri özeti alınamadı"}
221
 
222
+ def check_model_exists(self, model_name: str, version: str) -> dict:
223
+ """Check if a model already exists in the leaderboard"""
224
  try:
225
+ logger.info(f"Checking if model exists: {model_name}:{version}")
226
+
227
  df = self.leaderboard_data
228
  if df.empty:
229
+ logger.error("Leaderboard data is empty")
230
+ return {"exists": False, "error": "Leaderboard data is empty"}
231
+
232
+ # Create the combined model:version string
233
+ model_version = f"{model_name}:{version}"
234
+ logger.info(f"Looking for model_version: {model_version}")
235
+
236
+ # Check for exact match
237
+ exact_matches = df[df['model'] == model_version]
238
+
239
+ if not exact_matches.empty:
240
+ logger.info(f"Found exact match: {model_version}")
241
+ model_data = exact_matches.iloc[0].to_dict()
242
  return {
243
+ "exists": True,
244
+ "model_data": model_data,
245
+ "similar_models": []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  }
247
+
248
+ # Check for similar models (same base model, different versions)
249
+ similar_models = []
250
+ for _, row in df.iterrows():
251
+ if ':' in str(row['model']):
252
+ parts = str(row['model']).split(':', 1)
253
+ if len(parts) == 2 and parts[0] == model_name:
254
+ similar_models.append({
255
+ 'version': parts[1],
256
+ 'status': row.get('status', 'Bilinmiyor'),
257
+ 'basari': row.get('basari', 0)
258
+ })
259
+
260
+ logger.info(f"Found {len(similar_models)} similar models")
261
+
262
  return {
263
+ "exists": False,
264
+ "similar_models": similar_models
265
  }
266
+
267
  except Exception as e:
268
+ logger.error(f"Error checking model existence: {e}")
269
+ return {"exists": False, "error": str(e)}
 
 
 
 
270
 
271
  def clear_cache(self):
272
  """Tüm önbelleğe alınan verileri ve zaman damgalarını temizle."""
debug_hf_spaces.py ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Comprehensive debugging script for Hugging Face Spaces deployment
4
+ """
5
+
6
+ import logging
7
+ import sys
8
+ import time
9
+ import traceback
10
+ from pathlib import Path
11
+
12
+ import requests
13
+
14
+ # Set up comprehensive logging
15
+ logging.basicConfig(
16
+ level=logging.DEBUG,
17
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
18
+ handlers=[
19
+ logging.StreamHandler(sys.stdout),
20
+ logging.FileHandler('debug.log')
21
+ ]
22
+ )
23
+ logger = logging.getLogger(__name__)
24
+
25
+ def log_environment_info():
26
+ """Log environment information"""
27
+ logger.info("=== ENVIRONMENT INFORMATION ===")
28
+ logger.info(f"Python version: {sys.version}")
29
+ logger.info(f"Platform: {sys.platform}")
30
+
31
+ try:
32
+ import gradio as gr
33
+ logger.info(f"Gradio version: {gr.__version__}")
34
+ except Exception as e:
35
+ logger.error(f"Gradio import failed: {e}")
36
+
37
+ try:
38
+ import pandas as pd
39
+ logger.info(f"Pandas version: {pd.__version__}")
40
+ except Exception as e:
41
+ logger.error(f"Pandas import failed: {e}")
42
+
43
+ try:
44
+ import requests
45
+ logger.info(f"Requests version: {requests.__version__}")
46
+ except Exception as e:
47
+ logger.error(f"Requests import failed: {e}")
48
+
49
+ def test_basic_requests():
50
+ """Test basic requests functionality"""
51
+ logger.info("=== TESTING BASIC REQUESTS ===")
52
+
53
+ test_urls = [
54
+ "https://httpbin.org/get",
55
+ "https://ollama.com",
56
+ "https://huggingface.co"
57
+ ]
58
+
59
+ for url in test_urls:
60
+ try:
61
+ logger.info(f"Testing {url}")
62
+ response = requests.get(url, timeout=30)
63
+ logger.info(f"✅ {url} - Status: {response.status_code}")
64
+ logger.info(f" Content length: {len(response.text)}")
65
+ except requests.exceptions.Timeout:
66
+ logger.error(f"❌ {url} - Timeout")
67
+ except requests.exceptions.ConnectionError as e:
68
+ logger.error(f"❌ {url} - Connection error: {e}")
69
+ except Exception as e:
70
+ logger.error(f"❌ {url} - Error: {e}")
71
+
72
+ def test_model_validator_import():
73
+ """Test model validator import and basic functionality"""
74
+ logger.info("=== TESTING MODEL VALIDATOR ===")
75
+
76
+ try:
77
+ from model_validator import model_validator
78
+ logger.info("✅ Model validator imported successfully")
79
+
80
+ # Test basic functionality
81
+ logger.info("Testing model validator with simple request...")
82
+ result = model_validator.validate_ollama_model("llama2", "7b")
83
+ logger.info(f"✅ Model validation result: {result}")
84
+
85
+ except ImportError as e:
86
+ logger.error(f"❌ Import error: {e}")
87
+ logger.error(f"Traceback: {traceback.format_exc()}")
88
+ except Exception as e:
89
+ logger.error(f"❌ Model validator error: {e}")
90
+ logger.error(f"Traceback: {traceback.format_exc()}")
91
+
92
+ def test_data_manager_import():
93
+ """Test data manager import and basic functionality"""
94
+ logger.info("=== TESTING DATA MANAGER ===")
95
+
96
+ try:
97
+ from data_manager import data_manager
98
+ logger.info("✅ Data manager imported successfully")
99
+
100
+ # Test basic functionality
101
+ logger.info("Testing data manager with simple request...")
102
+ result = data_manager.check_model_exists("llama2", "7b")
103
+ logger.info(f"✅ Data manager result: {result}")
104
+
105
+ except ImportError as e:
106
+ logger.error(f"❌ Import error: {e}")
107
+ logger.error(f"Traceback: {traceback.format_exc()}")
108
+ except Exception as e:
109
+ logger.error(f"❌ Data manager error: {e}")
110
+ logger.error(f"Traceback: {traceback.format_exc()}")
111
+
112
+ def test_gradio_interface():
113
+ """Test Gradio interface creation"""
114
+ logger.info("=== TESTING GRADIO INTERFACE ===")
115
+
116
+ try:
117
+ import gradio as gr
118
+ logger.info("✅ Gradio imported successfully")
119
+
120
+ # Test basic interface creation
121
+ with gr.Blocks() as demo:
122
+ gr.Textbox(label="Test")
123
+ gr.Button("Test")
124
+
125
+ logger.info("✅ Basic Gradio interface created successfully")
126
+
127
+ except Exception as e:
128
+ logger.error(f"❌ Gradio interface error: {e}")
129
+ logger.error(f"Traceback: {traceback.format_exc()}")
130
+
131
+ def test_ui_imports():
132
+ """Test UI module imports"""
133
+ logger.info("=== TESTING UI IMPORTS ===")
134
+
135
+ ui_modules = [
136
+ "ui_main",
137
+ "ui_leaderboard",
138
+ "ui_submit_model",
139
+ "ui_evaluation_requests",
140
+ "ui_model_responses",
141
+ "ui_model_section_scores"
142
+ ]
143
+
144
+ for module_name in ui_modules:
145
+ try:
146
+ module = __import__(module_name)
147
+ logger.info(f"✅ {module_name} imported successfully")
148
+ except Exception as e:
149
+ logger.error(f"❌ {module_name} import failed: {e}")
150
+ logger.error(f"Traceback: {traceback.format_exc()}")
151
+
152
+ def test_full_app_startup():
153
+ """Test full app startup"""
154
+ logger.info("=== TESTING FULL APP STARTUP ===")
155
+
156
+ try:
157
+ # Test main app import
158
+ from app import main
159
+ logger.info("✅ Main app imported successfully")
160
+
161
+ # Test data manager initialization
162
+ from data_manager import DataManager
163
+ dm = DataManager()
164
+ logger.info("✅ Data manager initialized successfully")
165
+
166
+ # Test model validator initialization
167
+ from model_validator import OllamaModelValidator
168
+ validator = OllamaModelValidator()
169
+ logger.info("✅ Model validator initialized successfully")
170
+
171
+ except Exception as e:
172
+ logger.error(f"❌ Full app startup error: {e}")
173
+ logger.error(f"Traceback: {traceback.format_exc()}")
174
+
175
+ def main():
176
+ """Run all debugging tests"""
177
+ logger.info("Starting comprehensive Hugging Face Spaces debugging...")
178
+
179
+ log_environment_info()
180
+ time.sleep(1)
181
+
182
+ test_basic_requests()
183
+ time.sleep(1)
184
+
185
+ test_model_validator_import()
186
+ time.sleep(1)
187
+
188
+ test_data_manager_import()
189
+ time.sleep(1)
190
+
191
+ test_gradio_interface()
192
+ time.sleep(1)
193
+
194
+ test_ui_imports()
195
+ time.sleep(1)
196
+
197
+ test_full_app_startup()
198
+
199
+ logger.info("=== DEBUGGING COMPLETED ===")
200
+ logger.info("Check the debug.log file for detailed information")
201
+
202
+ if __name__ == "__main__":
203
+ main()
model_validator.py CHANGED
@@ -17,28 +17,45 @@ class OllamaModelValidator:
17
  "User-Agent": "Turkish-MMLU-Benchmark/1.0",
18
  "Accept": "text/html",
19
  })
20
- self.session.timeout = 10
21
 
22
  def fetch_model_html(self, model_name: str, version: str = None) -> str:
23
  """Fetch model HTML from Ollama library"""
24
- try:
25
- path = f"/library/{model_name}"
26
- if version:
27
- path += f":{version}"
28
-
29
- url = f"{self.base_url}{path}"
30
- logger.info(f"Fetching model HTML from: {url}")
31
-
32
- response = self.session.get(url)
33
-
34
- if response.status_code == 200:
35
- return response.text
36
- else:
37
- raise Exception(f"Failed to fetch model page: {response.status_code}")
38
 
39
- except Exception as e:
40
- logger.error(f"Error fetching model HTML: {e}")
41
- raise
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  def parse_model_html(self, html: str) -> Dict:
44
  """Parse model HTML to extract parameter size and available tags"""
 
17
  "User-Agent": "Turkish-MMLU-Benchmark/1.0",
18
  "Accept": "text/html",
19
  })
20
+ self.session.timeout = 30 # Increased timeout for HF Spaces
21
 
22
  def fetch_model_html(self, model_name: str, version: str = None) -> str:
23
  """Fetch model HTML from Ollama library"""
24
+ max_retries = 3
25
+ for attempt in range(max_retries):
26
+ try:
27
+ path = f"/library/{model_name}"
28
+ if version:
29
+ path += f":{version}"
 
 
 
 
 
 
 
 
30
 
31
+ url = f"{self.base_url}{path}"
32
+ logger.info(f"Fetching model HTML from: {url} (attempt {attempt + 1}/{max_retries})")
33
+
34
+ response = self.session.get(url)
35
+
36
+ if response.status_code == 200:
37
+ logger.info(f"Successfully fetched HTML from {url}")
38
+ return response.text
39
+ elif response.status_code == 404:
40
+ logger.warning(f"Model not found: {url}")
41
+ raise Exception(f"Model not found: {model_name}:{version}")
42
+ else:
43
+ logger.warning(f"HTTP {response.status_code} for {url}")
44
+ raise Exception(f"Failed to fetch model page: {response.status_code}")
45
+
46
+ except requests.exceptions.Timeout:
47
+ logger.warning(f"Timeout on attempt {attempt + 1} for {url}")
48
+ if attempt == max_retries - 1:
49
+ raise Exception(f"Request timeout after {max_retries} attempts")
50
+ continue
51
+ except requests.exceptions.ConnectionError as e:
52
+ logger.warning(f"Connection error on attempt {attempt + 1}: {e}")
53
+ if attempt == max_retries - 1:
54
+ raise Exception(f"Connection failed after {max_retries} attempts: {e}")
55
+ continue
56
+ except Exception as e:
57
+ logger.error(f"Error fetching model HTML: {e}")
58
+ raise
59
 
60
  def parse_model_html(self, html: str) -> Dict:
61
  """Parse model HTML to extract parameter size and available tags"""
test_hf_spaces.py ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Test script for debugging Hugging Face Spaces deployment issues
4
+ """
5
+
6
+ import logging
7
+ import time
8
+
9
+ import requests
10
+
11
+ # Set up logging
12
+ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
13
+ logger = logging.getLogger(__name__)
14
+
15
+ def test_basic_connectivity():
16
+ """Test basic internet connectivity"""
17
+ logger.info("Testing basic connectivity...")
18
+
19
+ test_urls = [
20
+ "https://ollama.com",
21
+ "https://huggingface.co",
22
+ "https://google.com"
23
+ ]
24
+
25
+ for url in test_urls:
26
+ try:
27
+ logger.info(f"Testing connection to {url}")
28
+ response = requests.get(url, timeout=10)
29
+ logger.info(f"✅ {url} - Status: {response.status_code}")
30
+ except Exception as e:
31
+ logger.error(f"❌ {url} - Error: {e}")
32
+
33
+ def test_ollama_scraping():
34
+ """Test Ollama website scraping"""
35
+ logger.info("Testing Ollama scraping...")
36
+
37
+ try:
38
+ # Test basic page fetch
39
+ url = "https://ollama.com/library/llama2"
40
+ logger.info(f"Fetching {url}")
41
+
42
+ session = requests.Session()
43
+ session.headers.update({
44
+ "User-Agent": "Turkish-MMLU-Benchmark/1.0",
45
+ "Accept": "text/html",
46
+ })
47
+ session.timeout = 30
48
+
49
+ response = session.get(url)
50
+ logger.info(f"✅ Ollama page fetch - Status: {response.status_code}")
51
+ logger.info(f"Content length: {len(response.text)} characters")
52
+
53
+ # Check if content contains expected elements
54
+ if "llama2" in response.text.lower():
55
+ logger.info("✅ Content contains expected model name")
56
+ else:
57
+ logger.warning("⚠️ Content doesn't contain expected model name")
58
+
59
+ except Exception as e:
60
+ logger.error(f"❌ Ollama scraping test failed: {e}")
61
+
62
+ def test_model_validator():
63
+ """Test the model validator"""
64
+ logger.info("Testing model validator...")
65
+
66
+ try:
67
+ from model_validator import OllamaModelValidator
68
+
69
+ validator = OllamaModelValidator()
70
+
71
+ # Test with a known model
72
+ result = validator.validate_ollama_model("llama2", "7b")
73
+
74
+ logger.info(f"✅ Model validation result: {result.get('valid', False)}")
75
+ if result.get('valid'):
76
+ logger.info(f"Parameter size: {result.get('parameter_size')}")
77
+ logger.info(f"RAM requirements: {result.get('ram_requirements')}")
78
+ else:
79
+ logger.info(f"Validation error: {result.get('error')}")
80
+
81
+ except Exception as e:
82
+ logger.error(f"❌ Model validator test failed: {e}")
83
+
84
+ def test_data_manager():
85
+ """Test the data manager"""
86
+ logger.info("Testing data manager...")
87
+
88
+ try:
89
+ from data_manager import DataManager
90
+
91
+ dm = DataManager()
92
+
93
+ # Test leaderboard data
94
+ leaderboard = dm.leaderboard_data
95
+ logger.info(f"✅ Leaderboard data loaded - {len(leaderboard)} rows")
96
+
97
+ # Test model existence check
98
+ result = dm.check_model_exists("llama2", "7b")
99
+ logger.info(f"✅ Model existence check: {result}")
100
+
101
+ except Exception as e:
102
+ logger.error(f"❌ Data manager test failed: {e}")
103
+
104
+ if __name__ == "__main__":
105
+ logger.info("Starting Hugging Face Spaces compatibility tests...")
106
+
107
+ test_basic_connectivity()
108
+ time.sleep(1)
109
+
110
+ test_ollama_scraping()
111
+ time.sleep(1)
112
+
113
+ test_model_validator()
114
+ time.sleep(1)
115
+
116
+ test_data_manager()
117
+
118
+ logger.info("All tests completed!")
ui_submit_model.py CHANGED
@@ -45,31 +45,58 @@ def add_submit_model_tab(block, api_service):
45
  with gr.Row():
46
  validate_btn = gr.Button("🔍 Model Doğrula", variant="secondary", size="lg")
47
  submit_btn = gr.Button("🚀 Model Gönder", variant="primary", size="lg", interactive=False)
 
48
 
49
  validation_output = gr.HTML()
50
  submission_output = gr.HTML()
 
51
 
52
  # Store validation result
53
  validation_result = gr.State(None)
54
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  def handle_validation(model_name, version):
56
  """Model doğrulama işlemi"""
57
  try:
 
 
58
  # Validation
59
  if not model_name or not model_name.strip():
 
60
  return (
61
  f'<div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">❌ Hata: Model adı gereklidir</div>',
62
  None
63
  )
64
 
65
  if not version or not version.strip():
 
66
  return (
67
  f'<div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">❌ Hata: Versiyon gereklidir</div>',
68
  None
69
  )
70
 
 
71
  # Check if model already exists in the leaderboard dataset
72
- model_check = data_manager.check_model_exists(model_name.strip(), version.strip())
 
 
 
 
 
 
 
 
73
 
74
  if model_check['exists']:
75
  # Model already exists
@@ -82,6 +109,7 @@ def add_submit_model_tab(block, api_service):
82
  basari_percent = f"{basari:.2f}%" if isinstance(basari, (int, float)) else "0.00%"
83
  progress_percent = f"{progress * 100:.2f}%" if isinstance(progress, (int, float)) else "0.00%"
84
 
 
85
  return (
86
  f'''
87
  <div style="color: orange; padding: 15px; border: 1px solid orange; border-radius: 8px; background: #fffbeb;">
@@ -97,8 +125,25 @@ def add_submit_model_tab(block, api_service):
97
  None
98
  )
99
 
 
100
  # Validate with Ollama
101
- validation = model_validator.validate_ollama_model(model_name.strip(), version.strip())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
  if validation['valid']:
104
  # Format validation details
@@ -141,6 +186,7 @@ def add_submit_model_tab(block, api_service):
141
  </div>
142
  '''
143
 
 
144
  return html_output, validation
145
  else:
146
  error_msg = validation.get('error', 'Bilinmeyen hata')
@@ -154,6 +200,7 @@ def add_submit_model_tab(block, api_service):
154
  tags_info += f"<br><strong>Önerilen versiyon:</strong> {suggested_version}"
155
  tags_info += "<br><strong>Önerilen:</strong> Yukarıdaki versiyonlardan birini kullanın."
156
 
 
157
  return (
158
  f'''
159
  <div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">
@@ -170,115 +217,106 @@ def add_submit_model_tab(block, api_service):
170
  f'''
171
  <div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">
172
  ❌ <strong>Sistem Hatası!</strong><br>
173
- <strong>Hata:</strong> {str(e)}
 
174
  </div>
175
  ''',
176
  None
177
  )
178
 
179
- def update_submit_button(validation_data):
180
- """Update submit button state based on validation result"""
181
- if validation_data and validation_data.get('valid', False) and validation_data.get('can_load', False):
 
 
 
 
182
  return gr.Button(interactive=True)
183
  else:
184
  return gr.Button(interactive=False)
185
 
186
  def handle_submission(model_name, version, validation_data):
187
- """Model gönderimi işle"""
188
  try:
189
- # Check if validation was successful
190
- if not validation_data:
191
- return (
192
- f'<div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">❌ Hata: Önce modeli doğrulayın</div>',
193
- model_name, version
194
- )
195
 
196
- # Check if model can be loaded (using 20GB limit)
197
- if not validation_data.get('can_load', False):
198
  return (
199
  f'''
200
  <div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">
201
- ❌ <strong>Model Çok Büyük!</strong><br>
202
- <strong>Hata:</strong> Model {validation_data['model']}:{validation_data['version']} 20GB'dan fazla RAM gerektiriyor<br>
203
- <strong>Parametre Boyutu:</strong> {validation_data['parameter_size']}B<br>
204
- <strong>RAM Gereksinimleri:</strong><br>
205
- • 16-bit: {validation_data['ram_requirements']['16-bit']}GB<br>
206
- • 8-bit: {validation_data['ram_requirements']['8-bit']}GB<br>
207
- • 4-bit: {validation_data['ram_requirements']['4-bit']}GB<br>
208
- <strong>Önerilen:</strong> Daha küçük bir model veya farklı quantization seçin
209
  </div>
210
  ''',
211
- model_name, version
212
  )
213
 
214
- # Check if model already exists in leaderboard before submitting
215
- model_check = data_manager.check_model_exists(model_name.strip(), version.strip())
216
- evaluation_info = ""
217
-
218
- if model_check['exists']:
219
- existing_model = model_check['model_data']
220
- basari = existing_model.get('basari', 0)
221
- basari_percent = f"{basari:.2f}%" if isinstance(basari, (int, float)) else "0.00%"
222
- evaluation_info = f"<br><br>⚠️ <strong>Değerlendirme Bilgisi:</strong> Bu model zaten değerlendirilmiş (Başarı: {basari_percent})"
223
- elif 'similar_models' in model_check:
224
- similar_models = model_check['similar_models']
225
- evaluation_info = f"<br><br>ℹ️ <strong>Benzer Modeller:</strong> "
226
- for similar in similar_models[:2]:
227
- basari_similar = f"{similar['basari']:.2f}%" if isinstance(similar['basari'], (int, float)) else "0.00%"
228
- evaluation_info += f"{similar['version']} (Başarı: {basari_similar}), "
229
- evaluation_info = evaluation_info.rstrip(", ")
230
-
231
- # API'ye gönder
232
- result = api_service.submit_model(model_name.strip(), version.strip())
233
 
234
- if result.get('success'):
235
- data = result.get('data', {})
236
- return (
237
- f'''
238
- <div style="color: green; padding: 15px; border: 1px solid green; border-radius: 8px; background: #f0fdf4;">
239
- ✅ <strong>Başarılı!</strong><br>
240
- <strong>Mesaj:</strong> {result.get('message')}<br>
241
- <strong>Model:</strong> {data.get('model', model_name)}<br>
242
- <strong>Versiyon:</strong> {data.get('version', version)}<br>
243
- <strong>Durum:</strong> {data.get('status', 'Beklemede')}<br>
244
- <strong>Oluşturulma:</strong> {data.get('created_at', 'Şimdi')}<br><br>
245
- <strong>Doğrulama Bilgileri:</strong><br>
246
- • Parametre Boyutu: {validation_data['parameter_size']}B<br>
247
- • Önerilen Quantization: {validation_data.get('recommended_quantization', 'Yok')}{evaluation_info}
248
- </div>
249
- ''',
250
- "", "" # Clear model name and version fields
251
  )
252
- else:
253
- # Check for specific error types
254
- error_message = result.get('message', 'Bilinmeyen hata')
255
- error_detail = result.get('error', 'Server error')
256
 
257
- # Handle HTTP 409 - Model already submitted
258
- if "409" in error_message or "409" in error_detail:
259
  return (
260
  f'''
261
- <div style="color: orange; padding: 15px; border: 1px solid orange; border-radius: 8px; background: #fffbeb;">
262
- ⚠️ <strong>Model Zaten Gönderilmiş!</strong><br><br>
263
  <strong>Model:</strong> {model_name}<br>
264
- <strong>Versiyon:</strong> {version}<br><br>
265
- <strong>Not:</strong> Bu model daha önce sisteme gönderilmiş ve değerlendirme kuyruğunda bulunmaktadır.<br>
266
- Lütfen farklı bir model veya versiyon deneyin.
267
  </div>
268
  ''',
269
- model_name, version # Keep the fields for user to modify
270
  )
271
  else:
 
 
272
  return (
273
  f'''
274
  <div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">
275
- ❌ <strong>Hata!</strong><br>
276
- <strong>Mesaj:</strong> {error_message}<br>
277
- <strong>Detay:</strong> {error_detail}
278
  </div>
279
  ''',
280
  model_name, version # Keep the fields for user to modify
281
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
282
 
283
  except Exception as e:
284
  logger.error(f"Model gönderimi hatası: {e}")
@@ -286,7 +324,8 @@ def add_submit_model_tab(block, api_service):
286
  f'''
287
  <div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">
288
  ❌ <strong>Sistem Hatası!</strong><br>
289
- <strong>Hata:</strong> {str(e)}
 
290
  </div>
291
  ''',
292
  model_name, version # Keep the fields for user to modify
@@ -299,6 +338,13 @@ def add_submit_model_tab(block, api_service):
299
  outputs=[validation_output, validation_result]
300
  )
301
 
 
 
 
 
 
 
 
302
  # Update submit button state when validation result changes
303
  validation_result.change(
304
  update_submit_button,
 
45
  with gr.Row():
46
  validate_btn = gr.Button("🔍 Model Doğrula", variant="secondary", size="lg")
47
  submit_btn = gr.Button("🚀 Model Gönder", variant="primary", size="lg", interactive=False)
48
+ debug_btn = gr.Button("🔧 Bağlantı Testi", variant="secondary", size="sm")
49
 
50
  validation_output = gr.HTML()
51
  submission_output = gr.HTML()
52
+ debug_output = gr.Textbox(label="Bağlantı Durumu", interactive=False)
53
 
54
  # Store validation result
55
  validation_result = gr.State(None)
56
 
57
+ def test_connectivity():
58
+ """Test basic connectivity for debugging"""
59
+ try:
60
+ import requests
61
+ response = requests.get("https://ollama.com", timeout=10)
62
+ if response.status_code == 200:
63
+ return "✅ Ollama.com erişilebilir"
64
+ else:
65
+ return f"❌ Ollama.com HTTP {response.status_code}"
66
+ except Exception as e:
67
+ return f"❌ Ollama.com erişilemiyor: {str(e)}"
68
+
69
  def handle_validation(model_name, version):
70
  """Model doğrulama işlemi"""
71
  try:
72
+ logger.info(f"Validation started for model: {model_name}:{version}")
73
+
74
  # Validation
75
  if not model_name or not model_name.strip():
76
+ logger.warning("Model name is empty")
77
  return (
78
  f'<div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">❌ Hata: Model adı gereklidir</div>',
79
  None
80
  )
81
 
82
  if not version or not version.strip():
83
+ logger.warning("Version is empty")
84
  return (
85
  f'<div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">❌ Hata: Versiyon gereklidir</div>',
86
  None
87
  )
88
 
89
+ logger.info("Checking if model exists in leaderboard dataset...")
90
  # Check if model already exists in the leaderboard dataset
91
+ try:
92
+ model_check = data_manager.check_model_exists(model_name.strip(), version.strip())
93
+ logger.info(f"Model check result: {model_check.get('exists', False)}")
94
+ except Exception as e:
95
+ logger.error(f"Error checking model existence: {e}")
96
+ return (
97
+ f'<div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">❌ <strong>Veri Kontrol Hatası!</strong><br><strong>Hata:</strong> {str(e)}</div>',
98
+ None
99
+ )
100
 
101
  if model_check['exists']:
102
  # Model already exists
 
109
  basari_percent = f"{basari:.2f}%" if isinstance(basari, (int, float)) else "0.00%"
110
  progress_percent = f"{progress * 100:.2f}%" if isinstance(progress, (int, float)) else "0.00%"
111
 
112
+ logger.info(f"Model already exists: {model_name}:{version}")
113
  return (
114
  f'''
115
  <div style="color: orange; padding: 15px; border: 1px solid orange; border-radius: 8px; background: #fffbeb;">
 
125
  None
126
  )
127
 
128
+ logger.info("Validating with Ollama...")
129
  # Validate with Ollama
130
+ try:
131
+ validation = model_validator.validate_ollama_model(model_name.strip(), version.strip())
132
+ logger.info(f"Ollama validation result: {validation.get('valid', False)}")
133
+ except Exception as e:
134
+ logger.error(f"Error validating with Ollama: {e}")
135
+ # In Hugging Face Spaces, we might have network issues, so provide a fallback
136
+ return (
137
+ f'''
138
+ <div style="color: orange; padding: 15px; border: 1px solid orange; border-radius: 8px; background: #fffbeb;">
139
+ ⚠️ <strong>Ollama Doğrulama Başarısız!</strong><br>
140
+ <strong>Hata:</strong> {str(e)}<br><br>
141
+ <strong>Not:</strong> Doğrulama başarısız oldu, ancak model gönderimi denenebilir.
142
+ Model adı ve versiyonun doğru olduğundan emin olun.
143
+ </div>
144
+ ''',
145
+ {"valid": True, "fallback": True, "model": model_name.strip(), "version": version.strip()}
146
+ )
147
 
148
  if validation['valid']:
149
  # Format validation details
 
186
  </div>
187
  '''
188
 
189
+ logger.info(f"Validation successful for {model_name}:{version}")
190
  return html_output, validation
191
  else:
192
  error_msg = validation.get('error', 'Bilinmeyen hata')
 
200
  tags_info += f"<br><strong>Önerilen versiyon:</strong> {suggested_version}"
201
  tags_info += "<br><strong>Önerilen:</strong> Yukarıdaki versiyonlardan birini kullanın."
202
 
203
+ logger.warning(f"Validation failed for {model_name}:{version} - {error_msg}")
204
  return (
205
  f'''
206
  <div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">
 
217
  f'''
218
  <div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">
219
  ❌ <strong>Sistem Hatası!</strong><br>
220
+ <strong>Hata:</strong> {str(e)}<br><br>
221
+ <strong>Not:</strong> Lütfen sayfayı yenileyin ve tekrar deneyin.
222
  </div>
223
  ''',
224
  None
225
  )
226
 
227
+ def update_submit_button(validation_result):
228
+ """Submit butonunun durumunu güncelle"""
229
+ if validation_result is None:
230
+ return gr.Button(interactive=False)
231
+
232
+ # Check if validation passed (including fallback)
233
+ if validation_result.get('valid', False):
234
  return gr.Button(interactive=True)
235
  else:
236
  return gr.Button(interactive=False)
237
 
238
  def handle_submission(model_name, version, validation_data):
239
+ """Model gönderimi işlemi"""
240
  try:
241
+ logger.info(f"Model submission started for: {model_name}:{version}")
 
 
 
 
 
242
 
243
+ if not validation_data or not validation_data.get('valid', False):
 
244
  return (
245
  f'''
246
  <div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">
247
+ ❌ <strong>Gönderim Hatası!</strong><br>
248
+ <strong>Hata:</strong> Model doğrulanmamış. Lütfen önce modeli doğrulayın.
 
 
 
 
 
 
249
  </div>
250
  ''',
251
+ model_name, version # Keep the fields for user to modify
252
  )
253
 
254
+ # Check if this is a fallback validation (no parameter_size)
255
+ if validation_data.get('fallback', False):
256
+ # For fallback cases, we don't have parameter_size, so we'll use default values
257
+ parameter_size = 7 # Default to 7B
258
+ logger.info(f"Using fallback parameter size: {parameter_size}B")
259
+ else:
260
+ # Get parameter size from validation
261
+ parameter_size = validation_data.get('parameter_size')
262
+ if not parameter_size:
263
+ return (
264
+ f'''
265
+ <div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">
266
+ <strong>Gönderim Hatası!</strong><br>
267
+ <strong>Hata:</strong> Model parametre boyutu belirlenemedi. Lütfen modeli tekrar doğrulayın.
268
+ </div>
269
+ ''',
270
+ model_name, version # Keep the fields for user to modify
271
+ )
272
+ logger.info(f"Using validated parameter size: {parameter_size}B")
273
 
274
+ # Submit to API
275
+ try:
276
+ result = api_service.submit_model(
277
+ model_name=model_name.strip(),
278
+ version=version.strip()
 
 
 
 
 
 
 
 
 
 
 
 
279
  )
 
 
 
 
280
 
281
+ if result.get('success'):
282
+ logger.info(f"Model submitted successfully: {model_name}:{version}")
283
  return (
284
  f'''
285
+ <div style="color: green; padding: 15px; border: 1px solid green; border-radius: 8px; background: #f0fdf4;">
286
+ <strong>Model Başarıyla Gönderildi!</strong><br><br>
287
  <strong>Model:</strong> {model_name}<br>
288
+ <strong>Versiyon:</strong> {version}<br>
289
+ <strong>Parametre Boyutu:</strong> {parameter_size}B<br><br>
290
+ <strong>Mesaj:</strong> {result.get('message', 'Model değerlendirme kuyruğuna eklendi.')}
291
  </div>
292
  ''',
293
+ "", "" # Clear model name and version fields
294
  )
295
  else:
296
+ error_msg = result.get('error', 'Bilinmeyen hata')
297
+ logger.error(f"API submission failed: {error_msg}")
298
  return (
299
  f'''
300
  <div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">
301
+ ❌ <strong>API Gönderim Hatası!</strong><br>
302
+ <strong>Hata:</strong> {error_msg}
 
303
  </div>
304
  ''',
305
  model_name, version # Keep the fields for user to modify
306
  )
307
+
308
+ except Exception as e:
309
+ logger.error(f"API submission exception: {e}")
310
+ return (
311
+ f'''
312
+ <div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">
313
+ ❌ <strong>API Bağlantı Hatası!</strong><br>
314
+ <strong>Hata:</strong> {str(e)}<br><br>
315
+ <strong>Not:</strong> API sunucusuna bağlanılamıyor. Lütfen daha sonra tekrar deneyin.
316
+ </div>
317
+ ''',
318
+ model_name, version # Keep the fields for user to modify
319
+ )
320
 
321
  except Exception as e:
322
  logger.error(f"Model gönderimi hatası: {e}")
 
324
  f'''
325
  <div style="color: red; padding: 15px; border: 1px solid red; border-radius: 8px; background: #fef2f2;">
326
  ❌ <strong>Sistem Hatası!</strong><br>
327
+ <strong>Hata:</strong> {str(e)}<br><br>
328
+ <strong>Not:</strong> Lütfen sayfayı yenileyin ve tekrar deneyin.
329
  </div>
330
  ''',
331
  model_name, version # Keep the fields for user to modify
 
338
  outputs=[validation_output, validation_result]
339
  )
340
 
341
+ # Connect debug button
342
+ debug_btn.click(
343
+ test_connectivity,
344
+ inputs=[],
345
+ outputs=[debug_output]
346
+ )
347
+
348
  # Update submit button state when validation result changes
349
  validation_result.change(
350
  update_submit_button,