Repository navigation
Feature/add UI - #3
LiteObject wants to merge 28 commits into
Conversation
- Introduced a Streamlit-based UI dashboard for monitoring RTSP processing. - Implemented an event broadcasting system for real-time updates. - Updated main application to support launching with a UI option. - Enhanced README and requirements to include Streamlit and related instructions. - Added tests for UI imports to ensure functionality without Streamlit installed.
… display with friendly timestamps
…atting, argument parsing, and UI imports
…e; improve event broadcasting with deque for memory efficiency; add context manager for notification dispatcher cleanup.
…s; update device discovery and message sending methods for improved performance and reliability.
…ing and saving of events to a JSON file for improved data retention and recovery.
…nhance logging and background service status checks.
…c context; implement thread handling to avoid event loop errors.
…shboard features, troubleshooting, and updated dependencies
…g and Google Hub broadcasting
…g and error handling. Update YOLOv8 model initialization for singleton pattern and improve UI dashboard metrics display.
There was a problem hiding this comment.
Pull Request Overview
This PR adds a comprehensive Streamlit UI dashboard for real-time monitoring of the RTSP processing system. The changes include creating a web-based interface with live event streaming, metrics tracking, and enhanced async support for Google Hub broadcasts, along with a sophisticated event broadcasting system for cross-process communication.
- Implements a real-time web dashboard with live metrics, image gallery, and event streaming
- Adds cross-process event broadcasting system using persistent JSON storage for UI updates
- Enhances async support in Google Hub communication with better error handling and timeout management
Reviewed Changes
Copilot reviewed 10 out of 13 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ui_dashboard.py | New Streamlit dashboard with real-time monitoring features and event display |
| src/event_broadcaster.py | New event broadcasting system for cross-process communication and persistence |
| src/services.py | Enhanced with event emission and cleanup methods for broadcaster integration |
| src/google_broadcast.py | Refactored to support async operations with proper zeroconf handling |
| src/app.py | Extended with UI launcher options and graceful shutdown handling |
| src/notification_dispatcher.py | Added context manager support and improved cleanup |
| run_ui.py | New standalone entry point for UI dashboard |
| README.md | Updated documentation with new UI features and troubleshooting |
|
|
||
| # Auto-refresh | ||
| if st.session_state.auto_refresh: | ||
| time.sleep(2) |
There was a problem hiding this comment.
Using time.sleep() in a Streamlit app can block the UI thread. Consider using st.empty() with a placeholder and manual refresh triggers instead of blocking sleep.
| time.sleep(2) | |
| placeholder = st.empty() | |
| for _ in range(20): # Adjust the range for a 2-second delay (20 iterations of 0.1s) | |
| time.sleep(0.1) | |
| placeholder.text("Refreshing...") |
| try: | ||
| # Create CastInfo for the known device | ||
| services = {HostServiceInfo(device_ip, port)} | ||
| services: Set[Union[HostServiceInfo, 'MDNSServiceInfo']] = { |
There was a problem hiding this comment.
Using forward reference string 'MDNSServiceInfo' suggests this type may not be properly imported. Consider importing the actual type or removing it from the type hint if not needed.
| services: Set[Union[HostServiceInfo, 'MDNSServiceInfo']] = { | |
| services: Set[Union[HostServiceInfo, MDNSServiceInfo]] = { |
| @@ -32,7 +36,6 @@ def __new__(cls, model_path='yolov8n.pt'): | |||
| with cls._lock: | |||
| if model_path not in cls._instances: | |||
| instance = super().__new__(cls) | |||
There was a problem hiding this comment.
The model initialization has been moved to init but the singleton pattern still creates the instance in new. This creates a race condition where _model might not be initialized when the instance is returned.
| instance = super().__new__(cls) | |
| instance = super().__new__(cls) | |
| instance._model = YOLO(model_path) # Initialize the model here |
| return False | ||
| finally: | ||
| # Explicit frame cleanup to free memory | ||
| del frame |
There was a problem hiding this comment.
Explicit del frame in finally block may cause issues if frame was not successfully created due to exceptions in earlier code. Consider checking if frame exists before deletion.
| del frame | |
| if 'frame' in locals() and frame is not None: | |
| del frame |
| - `streamlit` - Real-time web dashboard with live event updates | ||
| - `streamlit` - Real-time web dashboard (optional UI) | ||
|
|
There was a problem hiding this comment.
Duplicate streamlit entry in the dependencies list. One line says 'with live event updates' and the next says '(optional UI)'.
| - `streamlit` - Real-time web dashboard with live event updates | |
| - `streamlit` - Real-time web dashboard (optional UI) | |
| - `streamlit` - Real-time web dashboard with live event updates (optional UI) |
…nhance logging and background service status checks.
…enhance documentation for clarity.
…nhance logging and background service status checks.
…event-driven UI updates and performance optimizations.
…meter; update related function signatures and logging for improved message broadcasting.
… improve logging during shutdown process.
…patcher, and improve UI dashboard styling
…arious services - Implement tests for configuration validation in `test_config.py`, covering required fields and error reporting. - Create tests for event persistence in `test_event_persistence.py`, ensuring correct document writing and handling of concurrent reads. - Add tests for event schema functionality in `test_event_schema.py`, verifying event type stability and image path retrieval. - Introduce tests for Google Cast broadcast helpers in `test_google_broadcast.py`, validating message sending and playback handling. - Develop health check tests in `test_health_checks.py`, ensuring probes run off the event loop and handle exceptions correctly. - Implement image analysis tests in `test_image_analysis.py`, covering various response scenarios and provider failures. - Extend image capture tests in `test_image_capture.py` to include cleanup functionality for old images. - Add LLM factory tests in `test_llm_factory.py`, ensuring correct model defaults and parameter forwarding. - Create notification dispatcher tests in `test_notification_dispatcher.py`, validating async behavior and deduplication. - Implement service tests in `test_services.py` for frame processing, ensuring correct event emission and notification handling. - Add stream reader tests in `test_stream_reader.py`, verifying frame publishing and reconnection logic. - Extend TTS service tests in `test_tts.py` to cover engine selection and thread safety. - Implement UI formatting tests in `test_ui_formatting.py`, ensuring proper HTML escaping and event rendering. - Remove unused YOLOv8 model file `yolov8n.pt`.
- Introduced unit tests for the SQLite event store, covering event appending, querying, and retention policies. - Added tests for Google broadcast functionality, including local audio server and connection handling. - Implemented tests for image analysis, ensuring proper handling of unsupported providers and fallback mechanisms. - Enhanced image capture tests to validate frame saving and thumbnail generation. - Created an end-to-end integration test for the processing pipeline, simulating a fake camera and notification system. - Developed tests for LLM factory to ensure proper configuration and error handling. - Added tests for process image functions, ensuring correct base64 conversion and prompt generation. - Implemented service tests to validate analysis throttling and token budget management. - Introduced throttle tests to verify cooldown and hourly cap functionality. - Enhanced UI formatting tests to ensure proper event rendering and data masking.
…quality gates YAML file
…ns and styling improvements fix: implement secret redaction in error messages to prevent sensitive data exposure docs: update CHANGELOG for UI enhancements and security improvements; add new test cases for secret redaction
…with Material icons and CSV download functionality
…iguration options and update related tests
- Introduced runtime settings to enable/disable notifications and adjust Chromecast volume dynamically. - Updated dashboard to reflect changes in notification settings and volume. - Implemented new functions in `runtime_settings.py` for loading and saving settings. - Enhanced event store to retrieve events based on frame and image. - Modified notification dispatcher to utilize runtime volume settings. - Updated tests to cover new functionality and ensure proper behavior of runtime settings.
- Enhanced EventBroadcaster to emit events with an optional camera name. - Updated EventStore schema to include a camera column and added migration logic for legacy databases. - Implemented camera filtering in event retrieval methods and added methods for camera-specific statistics. - Modified health checks to support multiple RTSP streams based on configured cameras. - Introduced TokenBudget class to manage daily token limits shared across cameras. - Updated AsyncRTSPProcessingService to handle camera-specific processing and notifications. - Enhanced tests to cover new camera functionalities, including configuration validation and event emission.
No description provided.