Senum2001 commited on
Commit
68c41e5
·
1 Parent(s): a023a85

Deep fix: Add comprehensive state validation before logging training cycles to prevent type errors

Browse files
scripts/feedback_learning_pipeline.py CHANGED
@@ -327,17 +327,22 @@ class FeedbackLearningPipeline:
327
  if after_state and isinstance(after_state, dict):
328
  print(f"[Model Versioning] Captured state after training: {after_state.get('version_id', 'unknown')[:8]}...")
329
 
330
- # Log the training cycle with before/after comparison
331
- training_cycle_id = self.version_tracker.log_training_cycle(
332
- before_state=before_state,
333
- after_state=after_state,
334
- feedback_count=len(corrections),
335
- patterns=patterns,
336
- performance_metrics=None # TODO: Calculate actual metrics
337
- )
338
-
339
- if training_cycle_id:
340
- print(f"[Training History] Logged training cycle: {training_cycle_id[:8]}...")
 
 
 
 
 
341
  except Exception as e:
342
  print(f"[Model Versioning] Error logging version: {e}")
343
 
 
327
  if after_state and isinstance(after_state, dict):
328
  print(f"[Model Versioning] Captured state after training: {after_state.get('version_id', 'unknown')[:8]}...")
329
 
330
+ # Only log training cycle if both states are valid dictionaries
331
+ if (before_state and isinstance(before_state, dict) and
332
+ after_state and isinstance(after_state, dict)):
333
+ # Log the training cycle with before/after comparison
334
+ training_cycle_id = self.version_tracker.log_training_cycle(
335
+ before_state=before_state,
336
+ after_state=after_state,
337
+ feedback_count=len(corrections),
338
+ patterns=patterns,
339
+ performance_metrics=None # TODO: Calculate actual metrics
340
+ )
341
+
342
+ if training_cycle_id:
343
+ print(f"[Training History] Logged training cycle: {training_cycle_id[:8]}...")
344
+ else:
345
+ print(f"[Training History] Skipping cycle logging - invalid state data")
346
  except Exception as e:
347
  print(f"[Model Versioning] Error logging version: {e}")
348
 
scripts/model_versioning.py CHANGED
@@ -180,6 +180,11 @@ class ModelVersionTracker:
180
  Training cycle ID if successful
181
  """
182
  try:
 
 
 
 
 
183
  cycle_id = str(uuid.uuid4())
184
 
185
  # Calculate parameter changes
 
180
  Training cycle ID if successful
181
  """
182
  try:
183
+ # Validate inputs - ensure states are dictionaries
184
+ if not isinstance(before_state, dict) or not isinstance(after_state, dict):
185
+ print(f"[Training History] Error: Invalid state types - before: {type(before_state)}, after: {type(after_state)}")
186
+ return None
187
+
188
  cycle_id = str(uuid.uuid4())
189
 
190
  # Calculate parameter changes