Spaces:
Sleeping
Sleeping
Senum2001 commited on
Commit ·
90d4f4d
1
Parent(s): 68c41e5
Add comprehensive error handling and traceback logging to identify str.get() error source
Browse files- app.py +5 -0
- scripts/feedback_learning_pipeline.py +35 -23
app.py
CHANGED
|
@@ -41,6 +41,11 @@ def automated_training_check():
|
|
| 41 |
# Trigger training
|
| 42 |
results = run_feedback_training(feedback_pipeline)
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
if results.get("status") == "success":
|
| 45 |
print(f"[Automated Training] ✓ Training completed successfully")
|
| 46 |
print(f"[Automated Training] Processed {results.get('corrections_processed')} corrections")
|
|
|
|
| 41 |
# Trigger training
|
| 42 |
results = run_feedback_training(feedback_pipeline)
|
| 43 |
|
| 44 |
+
# Validate results is a dictionary
|
| 45 |
+
if not isinstance(results, dict):
|
| 46 |
+
print(f"[Automated Training] Error: Expected dict, got {type(results)}: {results}")
|
| 47 |
+
return
|
| 48 |
+
|
| 49 |
if results.get("status") == "success":
|
| 50 |
print(f"[Automated Training] ✓ Training completed successfully")
|
| 51 |
print(f"[Automated Training] Processed {results.get('corrections_processed')} corrections")
|
scripts/feedback_learning_pipeline.py
CHANGED
|
@@ -264,20 +264,21 @@ class FeedbackLearningPipeline:
|
|
| 264 |
"""
|
| 265 |
Execute a full training cycle: fetch feedback, analyze patterns, apply adjustments
|
| 266 |
"""
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
|
|
|
| 281 |
|
| 282 |
# Fetch new feedback
|
| 283 |
feedback_logs = self.fetch_new_feedback(limit=1000)
|
|
@@ -359,15 +360,26 @@ class FeedbackLearningPipeline:
|
|
| 359 |
return state
|
| 360 |
return None
|
| 361 |
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
|
| 372 |
def get_feedback_stats(self) -> Dict[str, Any]:
|
| 373 |
"""Get statistics about feedback and training"""
|
|
|
|
| 264 |
"""
|
| 265 |
Execute a full training cycle: fetch feedback, analyze patterns, apply adjustments
|
| 266 |
"""
|
| 267 |
+
try:
|
| 268 |
+
print(f"\n[Feedback Pipeline] Starting training cycle at {datetime.now()}")
|
| 269 |
+
|
| 270 |
+
# Capture model state BEFORE training
|
| 271 |
+
before_state = None
|
| 272 |
+
if self.version_tracker:
|
| 273 |
+
try:
|
| 274 |
+
before_state = self.version_tracker.get_current_model_state()
|
| 275 |
+
self.version_tracker.log_model_version(before_state)
|
| 276 |
+
if before_state and isinstance(before_state, dict):
|
| 277 |
+
print(f"[Model Versioning] Captured state before training: {before_state.get('version_id', 'unknown')[:8]}...")
|
| 278 |
+
except Exception as e:
|
| 279 |
+
print(f"[Model Versioning] Warning: Could not capture before state: {e}")
|
| 280 |
+
before_state = None # Reset to None on error
|
| 281 |
+
self.version_tracker = None # Disable versioning for this run
|
| 282 |
|
| 283 |
# Fetch new feedback
|
| 284 |
feedback_logs = self.fetch_new_feedback(limit=1000)
|
|
|
|
| 360 |
return state
|
| 361 |
return None
|
| 362 |
|
| 363 |
+
return {
|
| 364 |
+
"status": "success",
|
| 365 |
+
"corrections_processed": len(corrections),
|
| 366 |
+
"patterns": patterns,
|
| 367 |
+
"total_feedback_processed": self.training_state["total_feedback_processed"],
|
| 368 |
+
"before_version_id": _extract_version_id(before_state),
|
| 369 |
+
"after_version_id": _extract_version_id(after_state),
|
| 370 |
+
"training_cycle_id": training_cycle_id
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
except Exception as e:
|
| 374 |
+
print(f"[Feedback Pipeline] CRITICAL ERROR in run_training_cycle: {e}")
|
| 375 |
+
print(f"[Feedback Pipeline] Error type: {type(e).__name__}")
|
| 376 |
+
import traceback
|
| 377 |
+
traceback.print_exc()
|
| 378 |
+
return {
|
| 379 |
+
"status": "error",
|
| 380 |
+
"message": str(e),
|
| 381 |
+
"error_type": type(e).__name__
|
| 382 |
+
}
|
| 383 |
|
| 384 |
def get_feedback_stats(self) -> Dict[str, Any]:
|
| 385 |
"""Get statistics about feedback and training"""
|