Commit Graph

15 Commits

Author SHA1 Message Date
Urtzi Alfaro
5783c7ed05 Add POI feature and imporve the overall backend implementation 2025-11-12 15:34:10 +01:00
Urtzi Alfaro
74215d3e85 Fix deadlock issues in training 2025-11-05 18:47:20 +01:00
Urtzi Alfaro
fd0a96e254 Fix remaining nested session issues in training pipeline
Issues Fixed:

4️⃣ data_processor.py (Line 230-232):
- Second update_log_progress call without commit after data preparation
- Added commit() after completion update to prevent deadlock
- Added debug logging for visibility

5️⃣ prophet_manager.py _store_model (Line 750):
- Created TRIPLE nested session (training_service → trainer → lock → _store_model)
- Refactored _store_model to accept optional session parameter
- Uses parent session from lock context instead of creating new one
- Updated call site to pass db_session parameter

Complete Session Hierarchy After All Fixes:
training_service.py (session)
  └─ commit() ← FIX #2 (e585e9f)
  └─ trainer.py (new session)  OK
      └─ data_processor.py (new session)
          └─ commit() after first update ← FIX #3 (b2de56e)
          └─ commit() after second update ← FIX #4 (THIS)
      └─ prophet_manager.train_bakery_model (uses parent or new session) ← FIX #1 (caff497)
          └─ lock.acquire(session)
              └─ _store_model(session=parent) ← FIX #5 (THIS)
                  └─ NO NESTED SESSION 

All nested session deadlocks in training path are now resolved.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 16:41:53 +01:00
Urtzi Alfaro
b2de56ead3 Fix additional nested session deadlock in data_processor.py
Root Cause:
After fixing the training_service.py deadlock, training progressed to
data preparation but got stuck there. The data_processor.py creates
another nested session at line 143, updates training_log without
committing, causing another deadlock scenario.

Session Hierarchy:
1. training_service.py: outer session (fixed in e585e9f)
2. trainer.py: creates own session (passes deadlock due to commit)
3. data_processor.py: creates ANOTHER nested session (THIS FIX)

Fix:
Added explicit db_session.commit() after progress update in data_processor
(line 153) to ensure the UPDATE is committed before continuing with data
processing operations that may interact with other sessions.

This completes the chain of nested session fixes:
- caff497: prophet_manager + hybrid_trainer session passing
- e585e9f: training_service commit before trainer call
- THIS: data_processor commit after progress update

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 16:39:05 +01:00
Urtzi Alfaro
394ad3aea4 Improve AI logic 2025-11-05 13:34:56 +01:00
Urtzi Alfaro
3c689b4f98 REFACTOR external service and improve websocket training 2025-10-09 14:11:02 +02:00
Urtzi Alfaro
03737430ee Fix new services implementation 3 2025-08-14 16:47:34 +02:00
Urtzi Alfaro
fbe7470ad9 REFACTOR data service 2025-08-12 18:17:30 +02:00
Urtzi Alfaro
488bb3ef93 REFACTOR - Database logic 2025-08-08 09:08:41 +02:00
Urtzi Alfaro
024290e4c0 Start fixing forecast service 18 2025-07-30 08:41:47 +02:00
Urtzi Alfaro
c10a745695 Start fixing forecast service 17 2025-07-30 08:29:40 +02:00
Urtzi Alfaro
e5c3375d53 Start fixing forecast service 16 2025-07-30 08:13:32 +02:00
Urtzi Alfaro
7cd595df81 Improve training code 2 2025-07-28 20:20:54 +02:00
Urtzi Alfaro
98f546af12 Improve training code 2025-07-28 19:28:39 +02:00
Urtzi Alfaro
f3071c00bd Add all the code for training service 2025-07-19 16:59:37 +02:00