bug fixes
This commit is contained in:
@@ -16,6 +16,7 @@ from backend.src.core.superset_client import SupersetClient
|
|||||||
from superset_tool.models import SupersetConfig
|
from superset_tool.models import SupersetConfig
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
from backend.src.core.config_models import Environment as EnvModel
|
from backend.src.core.config_models import Environment as EnvModel
|
||||||
|
from backend.src.core.logger import belief_scope
|
||||||
# [/SECTION]
|
# [/SECTION]
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from fastapi import APIRouter, Depends
|
|||||||
|
|
||||||
from ...core.plugin_base import PluginConfig
|
from ...core.plugin_base import PluginConfig
|
||||||
from ...dependencies import get_plugin_loader
|
from ...dependencies import get_plugin_loader
|
||||||
|
from ...core.logger import belief_scope
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import os
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, List
|
from typing import Optional, List
|
||||||
from .config_models import AppConfig, Environment, GlobalSettings
|
from .config_models import AppConfig, Environment, GlobalSettings
|
||||||
from .logger import logger, configure_logger
|
from .logger import logger, configure_logger, belief_scope
|
||||||
# [/SECTION]
|
# [/SECTION]
|
||||||
|
|
||||||
# [DEF:ConfigManager:Class]
|
# [DEF:ConfigManager:Class]
|
||||||
|
|||||||
@@ -11,10 +11,11 @@
|
|||||||
# [SECTION: IMPORTS]
|
# [SECTION: IMPORTS]
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import sessionmaker, Session
|
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
|
# Import models to ensure they're registered with Base
|
||||||
from backend.src.models.task import TaskRecord
|
from ..models.task import TaskRecord
|
||||||
from backend.src.models.connection import ConnectionConfig
|
from ..models.connection import ConnectionConfig
|
||||||
|
from .logger import belief_scope
|
||||||
import os
|
import os
|
||||||
# [/SECTION]
|
# [/SECTION]
|
||||||
|
|
||||||
|
|||||||
@@ -142,9 +142,8 @@ class WebSocketLogHandler(logging.Handler):
|
|||||||
# @POST: Instance initialized with empty deque.
|
# @POST: Instance initialized with empty deque.
|
||||||
# @PARAM: capacity (int) - Maximum number of logs to keep in memory.
|
# @PARAM: capacity (int) - Maximum number of logs to keep in memory.
|
||||||
def __init__(self, capacity: int = 1000):
|
def __init__(self, capacity: int = 1000):
|
||||||
with belief_scope("WebSocketLogHandler.__init__"):
|
super().__init__()
|
||||||
super().__init__()
|
self.log_buffer: deque[LogEntry] = deque(maxlen=capacity)
|
||||||
self.log_buffer: deque[LogEntry] = deque(maxlen=capacity)
|
|
||||||
# In a real implementation, you'd have a way to manage active WebSocket connections
|
# In a real implementation, you'd have a way to manage active WebSocket connections
|
||||||
# e.g., self.active_connections: Set[WebSocket] = set()
|
# e.g., self.active_connections: Set[WebSocket] = set()
|
||||||
# [/DEF:__init__:Function]
|
# [/DEF:__init__:Function]
|
||||||
@@ -155,26 +154,25 @@ class WebSocketLogHandler(logging.Handler):
|
|||||||
# @POST: Log is added to the log_buffer.
|
# @POST: Log is added to the log_buffer.
|
||||||
# @PARAM: record (logging.LogRecord) - The log record to emit.
|
# @PARAM: record (logging.LogRecord) - The log record to emit.
|
||||||
def emit(self, record: logging.LogRecord):
|
def emit(self, record: logging.LogRecord):
|
||||||
with belief_scope("WebSocketLogHandler.emit"):
|
try:
|
||||||
try:
|
log_entry = LogEntry(
|
||||||
log_entry = LogEntry(
|
level=record.levelname,
|
||||||
level=record.levelname,
|
message=self.format(record),
|
||||||
message=self.format(record),
|
context={
|
||||||
context={
|
"name": record.name,
|
||||||
"name": record.name,
|
"pathname": record.pathname,
|
||||||
"pathname": record.pathname,
|
"lineno": record.lineno,
|
||||||
"lineno": record.lineno,
|
"funcName": record.funcName,
|
||||||
"funcName": record.funcName,
|
"process": record.process,
|
||||||
"process": record.process,
|
"thread": record.thread,
|
||||||
"thread": record.thread,
|
}
|
||||||
}
|
)
|
||||||
)
|
self.log_buffer.append(log_entry)
|
||||||
self.log_buffer.append(log_entry)
|
# Here you would typically send the log_entry to all active WebSocket connections
|
||||||
# Here you would typically send the log_entry to all active WebSocket connections
|
# for real-time streaming to the frontend.
|
||||||
# for real-time streaming to the frontend.
|
# Example: for ws in self.active_connections: await ws.send_json(log_entry.dict())
|
||||||
# Example: for ws in self.active_connections: await ws.send_json(log_entry.dict())
|
except Exception:
|
||||||
except Exception:
|
self.handleError(record)
|
||||||
self.handleError(record)
|
|
||||||
# [/DEF:emit:Function]
|
# [/DEF:emit:Function]
|
||||||
|
|
||||||
# [DEF:get_recent_logs:Function]
|
# [DEF:get_recent_logs:Function]
|
||||||
@@ -183,11 +181,10 @@ class WebSocketLogHandler(logging.Handler):
|
|||||||
# @POST: Returns list of LogEntry objects.
|
# @POST: Returns list of LogEntry objects.
|
||||||
# @RETURN: List[LogEntry] - List of buffered log entries.
|
# @RETURN: List[LogEntry] - List of buffered log entries.
|
||||||
def get_recent_logs(self) -> List[LogEntry]:
|
def get_recent_logs(self) -> List[LogEntry]:
|
||||||
with belief_scope("WebSocketLogHandler.get_recent_logs"):
|
"""
|
||||||
"""
|
Returns a list of recent log entries from the buffer.
|
||||||
Returns a list of recent log entries from the buffer.
|
"""
|
||||||
"""
|
return list(self.log_buffer)
|
||||||
return list(self.log_buffer)
|
|
||||||
# [/DEF:get_recent_logs:Function]
|
# [/DEF:get_recent_logs:Function]
|
||||||
|
|
||||||
# [/DEF:WebSocketLogHandler:Class]
|
# [/DEF:WebSocketLogHandler:Class]
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ from typing import List, Optional, Dict, Any
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from backend.src.models.task import TaskRecord
|
from ...models.task import TaskRecord
|
||||||
from backend.src.core.database import TasksSessionLocal
|
from ..database import TasksSessionLocal
|
||||||
from .models import Task, TaskStatus, LogEntry
|
from .models import Task, TaskStatus, LogEntry
|
||||||
from ..logger import logger, belief_scope
|
from ..logger import logger, belief_scope
|
||||||
# [/SECTION]
|
# [/SECTION]
|
||||||
|
|||||||
BIN
backend/tasks.db
BIN
backend/tasks.db
Binary file not shown.
Reference in New Issue
Block a user