diff --git a/backend/src/api/routes/environments.py b/backend/src/api/routes/environments.py index 6a0b8de..f1b2633 100644 --- a/backend/src/api/routes/environments.py +++ b/backend/src/api/routes/environments.py @@ -16,6 +16,7 @@ from backend.src.core.superset_client import SupersetClient from superset_tool.models import SupersetConfig from pydantic import BaseModel, Field from backend.src.core.config_models import Environment as EnvModel +from backend.src.core.logger import belief_scope # [/SECTION] router = APIRouter() diff --git a/backend/src/api/routes/plugins.py b/backend/src/api/routes/plugins.py index f47e853..ac5f14a 100755 --- a/backend/src/api/routes/plugins.py +++ b/backend/src/api/routes/plugins.py @@ -8,6 +8,7 @@ from fastapi import APIRouter, Depends from ...core.plugin_base import PluginConfig from ...dependencies import get_plugin_loader +from ...core.logger import belief_scope router = APIRouter() diff --git a/backend/src/core/config_manager.py b/backend/src/core/config_manager.py index 26856a5..7a578f7 100755 --- a/backend/src/core/config_manager.py +++ b/backend/src/core/config_manager.py @@ -16,7 +16,7 @@ import os from pathlib import Path from typing import Optional, List from .config_models import AppConfig, Environment, GlobalSettings -from .logger import logger, configure_logger +from .logger import logger, configure_logger, belief_scope # [/SECTION] # [DEF:ConfigManager:Class] diff --git a/backend/src/core/database.py b/backend/src/core/database.py index 681c6e4..84f49a7 100644 --- a/backend/src/core/database.py +++ b/backend/src/core/database.py @@ -11,10 +11,11 @@ # [SECTION: IMPORTS] from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker, Session -from backend.src.models.mapping import Base +from ..models.mapping import Base # Import models to ensure they're registered with Base -from backend.src.models.task import TaskRecord -from backend.src.models.connection import ConnectionConfig +from ..models.task import TaskRecord +from ..models.connection import ConnectionConfig +from .logger import belief_scope import os # [/SECTION] diff --git a/backend/src/core/logger.py b/backend/src/core/logger.py index cb0ef82..87177e4 100755 --- a/backend/src/core/logger.py +++ b/backend/src/core/logger.py @@ -142,9 +142,8 @@ class WebSocketLogHandler(logging.Handler): # @POST: Instance initialized with empty deque. # @PARAM: capacity (int) - Maximum number of logs to keep in memory. def __init__(self, capacity: int = 1000): - with belief_scope("WebSocketLogHandler.__init__"): - super().__init__() - self.log_buffer: deque[LogEntry] = deque(maxlen=capacity) + super().__init__() + self.log_buffer: deque[LogEntry] = deque(maxlen=capacity) # In a real implementation, you'd have a way to manage active WebSocket connections # e.g., self.active_connections: Set[WebSocket] = set() # [/DEF:__init__:Function] @@ -155,26 +154,25 @@ class WebSocketLogHandler(logging.Handler): # @POST: Log is added to the log_buffer. # @PARAM: record (logging.LogRecord) - The log record to emit. def emit(self, record: logging.LogRecord): - with belief_scope("WebSocketLogHandler.emit"): - try: - log_entry = LogEntry( - level=record.levelname, - message=self.format(record), - context={ - "name": record.name, - "pathname": record.pathname, - "lineno": record.lineno, - "funcName": record.funcName, - "process": record.process, - "thread": record.thread, - } - ) - self.log_buffer.append(log_entry) - # Here you would typically send the log_entry to all active WebSocket connections - # for real-time streaming to the frontend. - # Example: for ws in self.active_connections: await ws.send_json(log_entry.dict()) - except Exception: - self.handleError(record) + try: + log_entry = LogEntry( + level=record.levelname, + message=self.format(record), + context={ + "name": record.name, + "pathname": record.pathname, + "lineno": record.lineno, + "funcName": record.funcName, + "process": record.process, + "thread": record.thread, + } + ) + self.log_buffer.append(log_entry) + # Here you would typically send the log_entry to all active WebSocket connections + # for real-time streaming to the frontend. + # Example: for ws in self.active_connections: await ws.send_json(log_entry.dict()) + except Exception: + self.handleError(record) # [/DEF:emit:Function] # [DEF:get_recent_logs:Function] @@ -183,11 +181,10 @@ class WebSocketLogHandler(logging.Handler): # @POST: Returns list of LogEntry objects. # @RETURN: List[LogEntry] - List of buffered log entries. def get_recent_logs(self) -> List[LogEntry]: - with belief_scope("WebSocketLogHandler.get_recent_logs"): - """ - Returns a list of recent log entries from the buffer. - """ - return list(self.log_buffer) + """ + Returns a list of recent log entries from the buffer. + """ + return list(self.log_buffer) # [/DEF:get_recent_logs:Function] # [/DEF:WebSocketLogHandler:Class] diff --git a/backend/src/core/task_manager/persistence.py b/backend/src/core/task_manager/persistence.py index b3c4284..37eacd4 100644 --- a/backend/src/core/task_manager/persistence.py +++ b/backend/src/core/task_manager/persistence.py @@ -11,8 +11,8 @@ from typing import List, Optional, Dict, Any import json from sqlalchemy.orm import Session -from backend.src.models.task import TaskRecord -from backend.src.core.database import TasksSessionLocal +from ...models.task import TaskRecord +from ..database import TasksSessionLocal from .models import Task, TaskStatus, LogEntry from ..logger import logger, belief_scope # [/SECTION] diff --git a/backend/tasks.db b/backend/tasks.db index a299258..9b049cf 100644 Binary files a/backend/tasks.db and b/backend/tasks.db differ