ids.alfacom.it/deployment/install_ml_deps.sh
marco370 051c838840 Add ability to install ML dependencies and resolve build issues
Update install_ml_deps.sh to use --no-build-isolation when installing eif to resolve ModuleNotFoundError during build.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 219383e3-8935-415d-8c84-77e7d6f76af8
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/2lUhxO2
2025-11-24 17:06:43 +00:00

92 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
# Script per installare dipendenze ML Hybrid Detector
# Risolve il problema di build dependencies (Cython + numpy) richieste da eif
set -e
echo "╔═══════════════════════════════════════════════╗"
echo "║ INSTALLAZIONE DIPENDENZE ML HYBRID ║"
echo "╚═══════════════════════════════════════════════╝"
echo ""
# Vai alla directory python_ml
cd "$(dirname "$0")/../python_ml" || exit 1
echo "📍 Directory corrente: $(pwd)"
echo ""
# Verifica venv
if [ ! -d "venv" ]; then
echo "❌ ERRORE: Virtual environment non trovato in $(pwd)/venv"
echo " Esegui prima: python3 -m venv venv"
exit 1
fi
# Attiva venv
echo "🔧 Attivazione virtual environment..."
source venv/bin/activate
# Verifica che stiamo usando il venv
PYTHON_PATH=$(which python)
echo "📍 Python in uso: $PYTHON_PATH"
if [[ ! "$PYTHON_PATH" =~ "venv" ]]; then
echo "⚠️ WARNING: Non stiamo usando il venv correttamente!"
fi
echo ""
# STEP 1: Installa build dependencies PRIMA (Cython + numpy)
echo "📦 Step 1/3: Installazione build dependencies (Cython + numpy)..."
pip install Cython==3.0.5
if [ $? -eq 0 ]; then
echo "✅ Cython installato con successo"
else
echo "❌ Errore durante installazione Cython"
exit 1
fi
echo ""
# STEP 2: Verifica che numpy sia disponibile (già nei requirements base)
echo "📦 Step 2/3: Verifica numpy disponibile..."
python -c "import numpy; print(f'✅ numpy {numpy.__version__} già installato')" 2>/dev/null
if [ $? -ne 0 ]; then
echo "⚠️ numpy non trovato, installo..."
pip install numpy==1.26.2
fi
echo ""
# STEP 3: Installa dipendenze ML (ora Cython e numpy sono disponibili)
echo "📦 Step 3/3: Installazione dipendenze ML (xgboost, joblib, eif)..."
pip install xgboost==2.0.3 joblib==1.3.2
pip install --no-build-isolation eif==2.0.2
if [ $? -eq 0 ]; then
echo "✅ Dipendenze ML installate con successo"
else
echo "❌ Errore durante installazione dipendenze ML"
exit 1
fi
echo ""
echo "✅ INSTALLAZIONE COMPLETATA!"
echo ""
echo "🧪 Test import eif..."
python -c "from eif import iForest; print('✅ eif importato correttamente')"
if [ $? -eq 0 ]; then
echo ""
echo "✅ TUTTO OK! Hybrid ML Detector pronto per l'uso"
echo ""
echo "📋 Prossimi step:"
echo " 1. Testa sistema: python train_hybrid.py --mode test"
echo " 2. Training reale: python train_hybrid.py --mode train"
else
echo "❌ Errore durante test import eif"
exit 1
fi