- 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>
2.8 KiB
2.8 KiB
Code Quality Improvements - 29 November 2025
Summary
Continuation of code quality improvements from the previous session. Focus on exception handling, logging, and security.
Changes Made
1. Exception Handling Improvements
Replaced bare except: clauses with specific exception types:
-
core/detection/ollama_client.py
is_available(): Now catchesrequests.ConnectionError,requests.Timeoutlist_models(): Now catchesrequests.ConnectionError,requests.Timeout,json.JSONDecodeError,KeyError
-
core/embedding/faiss_manager.py
_save_index_only(): Now catchesOSError,IOErrorspecifically
-
core/capture/screen_capturer.py
capture_screen(): Now catchesOSError,ImportErrorspecifically
2. Logging Improvements
Replaced print() statements with proper logging calls in:
| File | print() removed | Logger added |
|---|---|---|
| core/detection/ui_detector.py | 21 | ✅ |
| core/detection/roi_optimizer.py | 6 | ✅ |
| core/embedding/state_embedding_builder.py | 8 | ✅ |
| core/graph/node_matcher.py | 7 | ✅ |
| core/embedding/faiss_manager.py | 2 | ✅ |
| core/capture/screen_capturer.py | 2 | ✅ |
Total: ~46 print() statements converted to logging
3. Security Improvements
- server/api_upload.py: Added production environment check for
ENCRYPTION_PASSWORD- Raises
ValueErrorif not set in production - Logs warning when using default key in development
- Raises
4. Configuration System
- core/config.py: Already complete centralized configuration system with:
ServerConfig: API and dashboard settingsSecurityConfig: Encryption and secrets with production validationModelConfig: ML model settings (CLIP, VLM, OWL)PathConfig: Directory paths with auto-creationFAISSConfig: Vector search settingsAppConfig: Main configuration aggregatorget_config(): Singleton pattern for global access
Test Results
All tests pass after changes:
- ✅ test_faiss_ivf_optimization.py (8/8 tests)
- ✅ test_roi_optimizer.py (12/12 tests)
Remaining print() Statements
13 print() statements remain, all in acceptable locations:
if __name__ == "__main__"blocks (test/example code)- Docstrings (documentation examples)
Files Modified
- core/detection/ollama_client.py
- core/detection/ui_detector.py
- core/detection/roi_optimizer.py
- core/embedding/faiss_manager.py
- core/embedding/state_embedding_builder.py
- core/graph/node_matcher.py
- core/capture/screen_capturer.py
- server/api_upload.py
Next Steps (if needed)
- Add type hints to remaining functions
- Add docstrings to undocumented functions
- Consider adding structured logging (JSON format) for production
- Add request validation with Pydantic models