From aefdcb38de9e2a14e3fcdd3116b7eed4654dbbce Mon Sep 17 00:00:00 2001 From: Ben_Kosytorz Date: Tue, 3 Mar 2026 00:08:58 +0100 Subject: [PATCH] refactor(api): simplify actix_web imports and remove unused modules - Removed unused imports (Scope, Arc, Mutex) from api/mod.rs - Updated config function signature to use ServiceConfig instead of Scope - Removed unused session_manager module from main.rs - Cleaned up documentation comments in models and queue_service modules - Simplified import statements across backend modules for better readability This refactoring removes unnecessary dependencies and cleans up the codebase by eliminating unused imports and redundant documentation while maintaining all functionality. --- backend/src/api/mod.rs | 8 +++----- backend/src/main.rs | 3 +-- backend/src/models/mod.rs | 11 ++++------- backend/src/queue_service/mod.rs | 11 ++++------- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/backend/src/api/mod.rs b/backend/src/api/mod.rs index ad7af04..21a7e87 100644 --- a/backend/src/api/mod.rs +++ b/backend/src/api/mod.rs @@ -3,10 +3,8 @@ //! This module defines all HTTP endpoints for the AI generation system, //! including model management, inference requests, and task status monitoring. -use actix_web::{web, HttpResponse, Result, Scope}; +use actix_web::{web, HttpResponse, Result}; use serde::{Deserialize, Serialize}; -use std::sync::Arc; -use tokio::sync::Mutex; use crate::{ AppState, @@ -158,11 +156,11 @@ pub async fn get_all_tasks(state: web::Data) -> Result { } /// Configuration for API routes -pub fn config(cfg: &mut Scope) { +pub fn config(cfg: &mut actix_web::web::ServiceConfig) { cfg.route("/health", web::get().to(health_check)) .route("/system-info", web::get().to(get_system_info)) .route("/models", web::get().to(get_models)) .route("/infer", web::post().to(start_inference)) .route("/tasks/{task_id}", web::get().to(get_task_status)) .route("/tasks", web::get().to(get_all_tasks)); -} \ No newline at end of file +} diff --git a/backend/src/main.rs b/backend/src/main.rs index 6d918e2..6f53e6e 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -3,7 +3,7 @@ //! This server provides a REST API and WebSocket endpoints for //! managing image/video generation workflows on AMD GPUs. -use actix_web::{web, App, HttpServer, Result, middleware::Logger}; +use actix_web::{web, App, HttpServer, middleware::Logger}; use serde::{Deserialize, Serialize}; use std::sync::Arc; use tokio::sync::Mutex; @@ -12,7 +12,6 @@ pub mod api; pub mod models; pub mod queue_service; pub mod rocminfo; -pub mod session_manager; #[derive(Debug, Clone)] pub struct AppState { diff --git a/backend/src/models/mod.rs b/backend/src/models/mod.rs index 27a0265..1939a29 100644 --- a/backend/src/models/mod.rs +++ b/backend/src/models/mod.rs @@ -1,13 +1,10 @@ -//! Model management for AI inference workflows -//! -//! This module handles loading, caching, and managing different types of -//! machine learning models needed for image/video generation. - use serde::{Deserialize, Serialize}; use std::collections::HashMap; -use std::sync::Arc; -use tokio::sync::Mutex; +/// Model management for AI inference workflows +/// +/// This module handles loading, caching, and managing different types of +/// machine learning models needed for image/video generation. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ModelInfo { pub name: String, diff --git a/backend/src/queue_service/mod.rs b/backend/src/queue_service/mod.rs index 1b1c2ec..385212b 100644 --- a/backend/src/queue_service/mod.rs +++ b/backend/src/queue_service/mod.rs @@ -1,15 +1,12 @@ -//! Task queue service for managing concurrent AI inference tasks -//! -//! This module provides a thread-safe task queue system using Tokio -//! and Rayon for parallel processing on AMD GPUs. - -use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::sync::Arc; use tokio::sync::{Mutex, Notify}; -use uuid::Uuid; +/// Task queue service for managing concurrent AI inference tasks +/// +/// This module provides a thread-safe task queue system using Tokio +/// and Rayon for parallel processing on AMD GPUs. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct Task { pub id: String,