From cf094bf750d62c3eac105296db73a8b8d46ec7f5 Mon Sep 17 00:00:00 2001 From: marco370 <48531002-marco370@users.noreply.replit.com> Date: Tue, 25 Nov 2025 08:01:03 +0000 Subject: [PATCH] Update model version tracking for training history Dynamically set the model version to "2.0.0" for hybrid detectors and "1.0.0" for legacy detectors, and update the database insertion logic in `main.py` to use this dynamic version. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 25db5356-3182-4db3-be10-c524c0561b39 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/RJGlbTt --- python_ml/main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python_ml/main.py b/python_ml/main.py index 21565a2..eede93d 100644 --- a/python_ml/main.py +++ b/python_ml/main.py @@ -62,6 +62,9 @@ app.add_middleware( # Global instances - Try hybrid first, fallback to legacy USE_HYBRID_DETECTOR = os.getenv("USE_HYBRID_DETECTOR", "true").lower() == "true" +# Model version based on detector type +MODEL_VERSION = "2.0.0" if USE_HYBRID_DETECTOR else "1.0.0" + if USE_HYBRID_DETECTOR: print("[ML] Using Hybrid ML Detector (Extended Isolation Forest + Feature Selection)") ml_detector = MLHybridDetector(model_dir="models") @@ -212,7 +215,7 @@ async def train_model(request: TrainRequest, background_tasks: BackgroundTasks): (model_version, records_processed, features_count, training_duration, status, notes) VALUES (%s, %s, %s, %s, %s, %s) """, ( - "1.0.0", + MODEL_VERSION, len(df), 0, 0, @@ -232,7 +235,7 @@ async def train_model(request: TrainRequest, background_tasks: BackgroundTasks): (model_version, records_processed, features_count, training_duration, status, notes) VALUES (%s, %s, %s, %s, %s, %s) """, ( - "1.0.0", + MODEL_VERSION, result['records_processed'], result['features_count'], 0, # duration non ancora implementato