Refactor deployment script and documentation to correctly handle build isolation for ML dependencies, specifically `eif`, by leveraging environment variables and sequential installation steps. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 7a4bce6a-9957-4807-aa16-ce07daafe00f Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/2lUhxO2
110 lines
3.1 KiB
Bash
Executable File
110 lines
3.1 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: Aggiorna pip/setuptools/wheel (critici per compilazione)
|
|
echo "📦 Step 1/4: Aggiornamento pip/setuptools/wheel..."
|
|
python -m pip install --upgrade pip setuptools wheel
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "✅ pip/setuptools/wheel aggiornati"
|
|
else
|
|
echo "❌ Errore durante aggiornamento pip"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# STEP 2: Installa build dependencies (Cython + numpy)
|
|
echo "📦 Step 2/4: Installazione build dependencies (Cython + numpy)..."
|
|
python -m pip install Cython==3.0.5 numpy==1.26.2
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "✅ Build dependencies installate"
|
|
else
|
|
echo "❌ Errore durante installazione build dependencies"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# STEP 3: Installa ML dependencies (xgboost, joblib)
|
|
echo "📦 Step 3/4: Installazione xgboost e joblib..."
|
|
python -m pip install xgboost==2.0.3 joblib==1.3.2
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "✅ xgboost e joblib installati"
|
|
else
|
|
echo "❌ Errore durante installazione xgboost/joblib"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# STEP 4: Installa eif con build isolation DISABILITATA (via env var)
|
|
echo "📦 Step 4/4: Installazione eif (compilazione senza isolamento)..."
|
|
export PIP_NO_BUILD_ISOLATION=1
|
|
python -m pip install --no-cache-dir 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 "📋 Verifica installazione:"
|
|
echo " python -c 'from eif import iForest; print(\"✅ eif OK\")'"
|
|
echo ""
|
|
echo "📋 Prossimi step:"
|
|
echo " 1. Test rapido: python train_hybrid.py --mode test"
|
|
echo " 2. Training completo: python train_hybrid.py --mode train"
|
|
else
|
|
echo "❌ Errore durante test import eif"
|
|
exit 1
|
|
fi
|