v1.0 - Version stable: multi-PC, détection UI-DETR-1, 3 modes exécution
- Frontend v4 accessible sur réseau local (192.168.1.40) - Ports ouverts: 3002 (frontend), 5001 (backend), 5004 (dashboard) - Ollama GPU fonctionnel - Self-healing interactif - Dashboard confiance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
329
docs/archive/misc/DIAGNOSTIC_WORKFLOWS_FAISS.md
Normal file
329
docs/archive/misc/DIAGNOSTIC_WORKFLOWS_FAISS.md
Normal file
@@ -0,0 +1,329 @@
|
||||
# 🔍 Diagnostic - Workflows et Performance FAISS
|
||||
|
||||
**Date**: 8 janvier 2026 - 00:15
|
||||
**Problèmes rapportés par l'utilisateur** :
|
||||
1. ❌ Workflows : 8 sessions traitées mais seulement 2 workflows (démo) visibles
|
||||
2. ❌ Performance : Onglet affiche 0 pour FAISS, embeddings, temps moyen
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Problème 1 - FAISS Non Initialisé (Performance à 0)
|
||||
|
||||
### Cause Racine
|
||||
**Fichier** : `/opt/rpa_vision_v3/server/processing_pipeline.py`
|
||||
**Ligne** : 86
|
||||
|
||||
**Code actuel** (incorrect) :
|
||||
```python
|
||||
self.faiss = FAISSManager(dimension=512) # ← dimension au singulier
|
||||
```
|
||||
|
||||
**Code attendu** par FAISSManager :
|
||||
```python
|
||||
def __init__(self,
|
||||
dimensions: int, # ← dimensions au pluriel
|
||||
index_type: str = "Flat",
|
||||
metric: str = "cosine",
|
||||
...):
|
||||
```
|
||||
|
||||
### Erreur dans les Logs
|
||||
```
|
||||
2026-01-07 22:09:17 [WARNING] processing_pipeline: Erreur init embeddings:
|
||||
FAISSManager.__init__() got an unexpected keyword argument 'dimension'
|
||||
```
|
||||
|
||||
### Impact
|
||||
1. L'initialisation de FAISSManager échoue
|
||||
2. `self.embeddings_available` devient `False`
|
||||
3. La méthode `_generate_embeddings()` est sautée
|
||||
4. Aucun embedding n'est généré ni indexé dans FAISS
|
||||
5. Le dashboard affiche 0 partout dans "Performance"
|
||||
|
||||
### Solution
|
||||
Corriger la typo :
|
||||
```python
|
||||
# AVANT
|
||||
self.faiss = FAISSManager(dimension=512)
|
||||
|
||||
# APRÈS
|
||||
self.faiss = FAISSManager(dimensions=512)
|
||||
```
|
||||
|
||||
**Complexité** : Triviale (1 caractère à ajouter)
|
||||
**Impact** : Les futures sessions auront leurs embeddings générés et indexés
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Problème 2 - Workflows Non Sauvegardés
|
||||
|
||||
### Cause Racine
|
||||
**Fichier** : `/opt/rpa_vision_v3/core/graph/graph_builder.py`
|
||||
**Lignes** : 539-545
|
||||
|
||||
**Problème** : Incompatibilité entre GraphBuilder et la nouvelle définition de ScreenTemplate
|
||||
|
||||
#### Code GraphBuilder (ancien, incompatible)
|
||||
```python
|
||||
def _build_screen_template(self, states, prototype_embedding):
|
||||
return ScreenTemplate(
|
||||
embedding_prototype=prototype_embedding.tolist(), # ← N'existe plus
|
||||
similarity_threshold=0.85, # ← N'existe plus
|
||||
window_title_pattern=None, # ← N'existe plus
|
||||
required_text_patterns=[], # ← N'existe plus
|
||||
required_ui_elements=[], # ← N'existe plus
|
||||
)
|
||||
```
|
||||
|
||||
#### Définition Actuelle de ScreenTemplate
|
||||
```python
|
||||
@dataclass
|
||||
class ScreenTemplate:
|
||||
window: WindowConstraint # ← Nouveau
|
||||
text: TextConstraint # ← Nouveau
|
||||
ui: UIConstraint # ← Nouveau
|
||||
embedding: EmbeddingPrototype # ← Nouveau (pas embedding_prototype)
|
||||
```
|
||||
|
||||
#### Définition de EmbeddingPrototype
|
||||
```python
|
||||
@dataclass
|
||||
class EmbeddingPrototype:
|
||||
provider: str # e.g., "openclip_ViT-B-32"
|
||||
vector_id: str # Chemin vers .npy du prototype
|
||||
min_cosine_similarity: float # Seuil de similarité
|
||||
sample_count: int # Nombre d'échantillons utilisés
|
||||
```
|
||||
|
||||
### Erreurs dans les Logs
|
||||
```
|
||||
2026-01-07 22:09:41 [ERROR] processing_pipeline:
|
||||
Erreur construction workflow: ScreenTemplate.__init__() got an unexpected
|
||||
keyword argument 'embedding_prototype'
|
||||
```
|
||||
|
||||
```
|
||||
2026-01-07 22:03:03 [ERROR] processing_pipeline:
|
||||
Erreur construction workflow: 'str' object does not support item assignment
|
||||
```
|
||||
|
||||
### Impact
|
||||
1. GraphBuilder tente de construire un workflow
|
||||
2. Échoue à la création du ScreenTemplate (incompatibilité API)
|
||||
3. `workflow_created` reste à `False`
|
||||
4. Aucun fichier workflow n'est sauvegardé
|
||||
5. L'utilisateur ne voit que les 2 workflows démo du 2 janvier
|
||||
|
||||
### Solution
|
||||
Réécrire `_build_screen_template()` pour utiliser la nouvelle API :
|
||||
|
||||
```python
|
||||
def _build_screen_template(self, states, prototype_embedding, cluster_id):
|
||||
"""
|
||||
Construire ScreenTemplate compatible avec nouvelle API
|
||||
"""
|
||||
# Sauvegarder le prototype embedding
|
||||
prototype_path = f"data/training/prototypes/cluster_{cluster_id}.npy"
|
||||
np.save(prototype_path, prototype_embedding)
|
||||
|
||||
# Créer EmbeddingPrototype
|
||||
embedding_proto = EmbeddingPrototype(
|
||||
provider="openclip_ViT-B-32",
|
||||
vector_id=prototype_path,
|
||||
min_cosine_similarity=0.85,
|
||||
sample_count=len(states)
|
||||
)
|
||||
|
||||
# Extraire contraintes depuis les états du cluster
|
||||
# TODO: Analyser les states pour extraire window_title, textes, etc.
|
||||
|
||||
# Créer les contraintes (basiques pour l'instant)
|
||||
window_constraint = WindowConstraint(
|
||||
title_contains=None, # TODO: Extraire du cluster
|
||||
process_name=None
|
||||
)
|
||||
|
||||
text_constraint = TextConstraint(
|
||||
required_texts=[], # TODO: Extraire patterns communs
|
||||
forbidden_texts=[]
|
||||
)
|
||||
|
||||
ui_constraint = UIConstraint(
|
||||
required_roles=[],
|
||||
required_types=[],
|
||||
min_element_count=0
|
||||
)
|
||||
|
||||
# Créer ScreenTemplate avec nouvelle API
|
||||
return ScreenTemplate(
|
||||
window=window_constraint,
|
||||
text=text_constraint,
|
||||
ui=ui_constraint,
|
||||
embedding=embedding_proto
|
||||
)
|
||||
```
|
||||
|
||||
**Complexité** : Moyenne (refactoring complet de la méthode)
|
||||
**Impact** : Les futures sessions pourront créer de vrais workflows
|
||||
|
||||
---
|
||||
|
||||
## 📊 État Actuel du Système
|
||||
|
||||
### Workflows
|
||||
```bash
|
||||
ls /opt/rpa_vision_v3/data/training/workflows/
|
||||
# Output: demo_calculator.json demo_notepad.json
|
||||
```
|
||||
- ✅ 2 workflows démo (créés le 2 janvier)
|
||||
- ❌ 0 workflows réels (GraphBuilder échoue)
|
||||
|
||||
### Embeddings/FAISS
|
||||
```bash
|
||||
ls /opt/rpa_vision_v3/data/training/embeddings/
|
||||
# Output: (vide)
|
||||
|
||||
ls /opt/rpa_vision_v3/data/training/faiss_index/
|
||||
# Output: (vide)
|
||||
```
|
||||
- ❌ Aucun embedding généré (FAISS non initialisé)
|
||||
- ❌ Aucun index FAISS créé
|
||||
|
||||
### Screen States (OK)
|
||||
```bash
|
||||
find /opt/rpa_vision_v3/data/training/screen_states -name "*.json" | wc -l
|
||||
# Output: 371
|
||||
```
|
||||
- ✅ 371 screen states créés et sauvegardés
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Plan de Correction
|
||||
|
||||
### Option 1 - Correction FAISS Seulement (RAPIDE)
|
||||
**Temps estimé** : 5 minutes
|
||||
**Complexité** : Triviale
|
||||
|
||||
**Actions** :
|
||||
1. Corriger typo `dimension` → `dimensions` dans processing_pipeline.py
|
||||
2. Redémarrer le worker
|
||||
3. Capturer une nouvelle session de test
|
||||
4. Vérifier que les embeddings sont générés
|
||||
|
||||
**Résultat** :
|
||||
- ✅ Performance FAISS affichera le nombre réel d'embeddings
|
||||
- ✅ Recherche par similarité fonctionnelle
|
||||
- ❌ Workflows toujours non créés (nécessite Option 2)
|
||||
|
||||
---
|
||||
|
||||
### Option 2 - Correction FAISS + Workflows (COMPLET)
|
||||
**Temps estimé** : 30-45 minutes
|
||||
**Complexité** : Moyenne
|
||||
|
||||
**Actions** :
|
||||
1. Corriger typo FAISS (comme Option 1)
|
||||
2. Réécrire `_build_screen_template()` dans graph_builder.py
|
||||
3. Créer dossier pour prototypes : `data/training/prototypes/`
|
||||
4. Redémarrer le worker
|
||||
5. Capturer une nouvelle session de test
|
||||
6. Vérifier création du workflow
|
||||
|
||||
**Résultat** :
|
||||
- ✅ Performance FAISS fonctionnelle
|
||||
- ✅ Workflows réels créés et visibles
|
||||
- ✅ Système complet et production-ready
|
||||
|
||||
---
|
||||
|
||||
### Option 3 - Reprocesser les Sessions Existantes (BONUS)
|
||||
**Prérequis** : Option 1 ou 2 complétée
|
||||
**Temps estimé** : 5 minutes + temps de traitement (dépend du volume)
|
||||
|
||||
**Actions** :
|
||||
1. Relancer le processing_pipeline sur les 8 sessions déjà capturées
|
||||
2. Les screen_states existent déjà, seuls embeddings/workflows seront générés
|
||||
|
||||
**Commande** :
|
||||
```bash
|
||||
for session_id in sess_20260107T*; do
|
||||
python3 /opt/rpa_vision_v3/server/processing_pipeline.py $session_id
|
||||
done
|
||||
```
|
||||
|
||||
**Résultat** :
|
||||
- ✅ 371 embeddings générés rétroactivement
|
||||
- ✅ 8 workflows créés depuis les sessions existantes
|
||||
- ✅ Dashboard complet sans recapturer de nouvelles sessions
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Recommandation
|
||||
|
||||
### Pour Démo Imminente
|
||||
**Option 1** (FAISS seulement) + capturer 1-2 nouvelles sessions
|
||||
- Rapide (10 minutes total)
|
||||
- Affiche des vraies métriques Performance
|
||||
- Workflows restent en démo mais c'est acceptable
|
||||
|
||||
### Pour Production-Ready
|
||||
**Option 2** (FAISS + Workflows) + **Option 3** (Reprocessing)
|
||||
- Complet (45-60 minutes)
|
||||
- Tous les bugs corrigés
|
||||
- 371 embeddings + 8 workflows réels
|
||||
- Système entièrement fonctionnel
|
||||
|
||||
---
|
||||
|
||||
## 📝 Fichiers à Modifier
|
||||
|
||||
### Correction FAISS
|
||||
```
|
||||
/opt/rpa_vision_v3/server/processing_pipeline.py
|
||||
Ligne 86 : dimension=512 → dimensions=512
|
||||
```
|
||||
|
||||
### Correction Workflows
|
||||
```
|
||||
/opt/rpa_vision_v3/core/graph/graph_builder.py
|
||||
Lignes 539-545 : Réécrire _build_screen_template()
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ✅ Critères de Succès
|
||||
|
||||
### Après Option 1 (FAISS)
|
||||
- [ ] Logs montrent "Embeddings générés: X" (X > 0)
|
||||
- [ ] Fichiers .npy créés dans `data/training/embeddings/`
|
||||
- [ ] Index FAISS créé dans `data/training/faiss_index/`
|
||||
- [ ] Dashboard Performance affiche nombre > 0
|
||||
|
||||
### Après Option 2 (Workflows)
|
||||
- [ ] Logs montrent "Workflow créé: True"
|
||||
- [ ] Fichiers .json créés dans `data/training/workflows/`
|
||||
- [ ] Dashboard Workflows affiche > 2 workflows
|
||||
- [ ] Aucune erreur "ScreenTemplate.__init__()"
|
||||
|
||||
---
|
||||
|
||||
## 💡 Notes Techniques
|
||||
|
||||
### Pourquoi le Code Est Incompatible ?
|
||||
Le projet a subi un **refactoring architectural majeur** entre :
|
||||
- **Version initiale** : ScreenTemplate avec champs simples (embedding_prototype, similarity_threshold)
|
||||
- **Version actuelle** : ScreenTemplate avec objets complexes (WindowConstraint, EmbeddingPrototype)
|
||||
|
||||
Le GraphBuilder n'a **pas été mis à jour** lors de ce refactoring.
|
||||
|
||||
### Impact sur les Données Existantes
|
||||
- ✅ Screen States : Format stable, pas d'impact
|
||||
- ❌ Embeddings : Jamais générés, pas d'impact (rien à migrer)
|
||||
- ❌ Workflows : Jamais créés, pas d'impact (rien à migrer)
|
||||
|
||||
---
|
||||
|
||||
**Que veux-tu faire ?**
|
||||
1. Option 1 (rapide, FAISS seulement)
|
||||
2. Option 2 (complet, FAISS + Workflows)
|
||||
3. Autre approche ?
|
||||
Reference in New Issue
Block a user