refactor: done phase 1
This commit is contained in:
parent
f7c464be21
commit
cbbed3d933
13 changed files with 1084 additions and 891 deletions
|
@ -113,50 +113,58 @@ core/
|
|||
|
||||
# Comprehensive TODO List
|
||||
|
||||
## 📋 Phase 1: Project Setup & Communication Layer
|
||||
## ✅ Phase 1: Project Setup & Communication Layer - COMPLETED
|
||||
|
||||
### 1.1 Project Structure Setup
|
||||
- [ ] Create `core/` directory structure
|
||||
- [ ] Create all module directories and `__init__.py` files
|
||||
- [ ] Set up logging configuration for new modules
|
||||
- [ ] Update imports in existing files to prepare for migration
|
||||
- ✅ Create `core/` directory structure
|
||||
- ✅ Create all module directories and `__init__.py` files
|
||||
- ✅ Set up logging configuration for new modules
|
||||
- ✅ Update imports in existing files to prepare for migration
|
||||
|
||||
### 1.2 Communication Module (`core/communication/`)
|
||||
- [ ] **Create `models.py`** - Message data structures
|
||||
- [ ] Define WebSocket message models (SubscriptionList, StateReport, etc.)
|
||||
- [ ] Add validation schemas for incoming messages
|
||||
- [ ] Create response models for outgoing messages
|
||||
- ✅ **Create `models.py`** - Message data structures
|
||||
- ✅ Define WebSocket message models (SubscriptionList, StateReport, etc.)
|
||||
- ✅ Add validation schemas for incoming messages
|
||||
- ✅ Create response models for outgoing messages
|
||||
|
||||
- [ ] **Create `messages.py`** - Message types and validation
|
||||
- [ ] Implement message type constants
|
||||
- [ ] Add message validation functions
|
||||
- [ ] Create message builders for common responses
|
||||
- ✅ **Create `messages.py`** - Message types and validation
|
||||
- ✅ Implement message type constants
|
||||
- ✅ Add message validation functions
|
||||
- ✅ Create message builders for common responses
|
||||
|
||||
- [ ] **Create `websocket.py`** - WebSocket message handling
|
||||
- [ ] Extract WebSocket connection management from `app.py`
|
||||
- [ ] Implement message routing and dispatching
|
||||
- [ ] Add connection lifecycle management (connect, disconnect, reconnect)
|
||||
- [ ] Handle `setSubscriptionList` message processing
|
||||
- [ ] Handle `setSessionId` and `setProgressionStage` messages
|
||||
- [ ] Handle `requestState` and `patchSessionResult` messages
|
||||
- ✅ **Create `websocket.py`** - WebSocket message handling
|
||||
- ✅ Extract WebSocket connection management from `app.py`
|
||||
- ✅ Implement message routing and dispatching
|
||||
- ✅ Add connection lifecycle management (connect, disconnect, reconnect)
|
||||
- ✅ Handle `setSubscriptionList` message processing
|
||||
- ✅ Handle `setSessionId` and `setProgressionStage` messages
|
||||
- ✅ Handle `requestState` and `patchSessionResult` messages
|
||||
|
||||
- [ ] **Create `state.py`** - Worker state management
|
||||
- [ ] Extract state reporting logic from `app.py`
|
||||
- [ ] Implement system metrics collection (CPU, memory, GPU)
|
||||
- [ ] Manage active subscriptions state
|
||||
- [ ] Handle session ID mapping and storage
|
||||
- ✅ **Create `state.py`** - Worker state management
|
||||
- ✅ Extract state reporting logic from `app.py`
|
||||
- ✅ Implement system metrics collection (CPU, memory, GPU)
|
||||
- ✅ Manage active subscriptions state
|
||||
- ✅ Handle session ID mapping and storage
|
||||
|
||||
### 1.3 HTTP API Preservation
|
||||
- [ ] **Preserve `/camera/{camera_id}/image` endpoint**
|
||||
- [ ] Extract REST API logic from `app.py`
|
||||
- [ ] Ensure frame caching mechanism works with new structure
|
||||
- [ ] Maintain exact same response format and error handling
|
||||
- ✅ **Preserve `/camera/{camera_id}/image` endpoint**
|
||||
- ✅ Extract REST API logic from `app.py`
|
||||
- ✅ Ensure frame caching mechanism works with new structure
|
||||
- ✅ Maintain exact same response format and error handling
|
||||
|
||||
### 1.4 Testing Phase 1
|
||||
- [ ] Test WebSocket connection and message handling
|
||||
- [ ] Test HTTP API endpoint functionality
|
||||
- [ ] Verify state reporting works correctly
|
||||
- [ ] Test session management functionality
|
||||
- ✅ Test WebSocket connection and message handling
|
||||
- ✅ Test HTTP API endpoint functionality
|
||||
- ✅ Verify state reporting works correctly
|
||||
- ✅ Test session management functionality
|
||||
|
||||
### 1.5 Phase 1 Results
|
||||
- ✅ **Modular Architecture**: Transformed ~900 lines into 4 focused modules (~200 lines each)
|
||||
- ✅ **WebSocket Protocol**: Full compliance with worker.md specification
|
||||
- ✅ **System Metrics**: Real-time CPU, memory, GPU monitoring
|
||||
- ✅ **State Management**: Thread-safe subscription and session tracking
|
||||
- ✅ **Backward Compatibility**: All existing endpoints preserved
|
||||
- ✅ **Modern FastAPI**: Lifespan events, Pydantic v2 compatibility
|
||||
|
||||
## 📋 Phase 2: Pipeline Configuration & Model Management
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue