mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
refactor: 移除 Python 后端源码,全面迁移至 Rust gateway 架构
- 删除全部 Python 源码 (src/) 及 Alembic 迁移脚本,归档至 _deprecated_py_src/ - 重构 Rust gateway ai_pipeline: 拆分 planner/finalize 模块,新增 contracts/adaptation 层 - 重组 handlers 模块为 admin/public/proxy/internal/shared 子模块结构 - 新增 executor 模块,引入 Rust 原生数据库迁移 (aether-data/migrations) - 简化 CI/Docker 构建流程,移除 base image 二级构建,统一为单一 app image - 移除 Python 相关基础设施文件 (entrypoint.sh, gunicorn_conf.py, Dockerfile.base)
This commit is contained in:
57
_deprecated_py_src/modules/__init__.py
Normal file
57
_deprecated_py_src/modules/__init__.py
Normal file
@@ -0,0 +1,57 @@
|
||||
"""
|
||||
功能模块注册 -- 自动发现
|
||||
|
||||
扫描 src/modules/ 下的子目录,自动查找 ModuleDefinition 实例。
|
||||
新增模块只需创建 src/modules/<name>/__init__.py 并导出 ModuleDefinition,无需修改此文件。
|
||||
"""
|
||||
|
||||
import importlib
|
||||
from pathlib import Path
|
||||
|
||||
from src.core.logger import logger
|
||||
from src.core.modules.base import ModuleDefinition
|
||||
|
||||
|
||||
def discover_modules() -> list[ModuleDefinition]:
|
||||
"""
|
||||
自动发现所有模块定义
|
||||
|
||||
扫描 src/modules/ 下的每个子目录,导入其 __init__.py,
|
||||
查找所有 ModuleDefinition 实例并返回。
|
||||
"""
|
||||
modules_dir = Path(__file__).parent
|
||||
discovered: list[ModuleDefinition] = []
|
||||
seen_names: set[str] = set()
|
||||
|
||||
for child in sorted(modules_dir.iterdir()):
|
||||
if not child.is_dir():
|
||||
continue
|
||||
if child.name.startswith("_"):
|
||||
continue
|
||||
if not (child / "__init__.py").exists():
|
||||
continue
|
||||
|
||||
module_path = f"src.modules.{child.name}"
|
||||
try:
|
||||
mod = importlib.import_module(module_path)
|
||||
except Exception as e:
|
||||
logger.error("Failed to import module {}: {}", module_path, e)
|
||||
continue
|
||||
|
||||
# 扫描模块顶层属性,查找 ModuleDefinition 实例
|
||||
for obj in vars(mod).values():
|
||||
if isinstance(obj, ModuleDefinition):
|
||||
name = obj.metadata.name
|
||||
if name in seen_names:
|
||||
logger.warning("Duplicate module name '{}' in {}, skipping", name, module_path)
|
||||
continue
|
||||
seen_names.add(name)
|
||||
discovered.append(obj)
|
||||
logger.debug("Discovered module: {} from {}", name, module_path)
|
||||
|
||||
return discovered
|
||||
|
||||
|
||||
ALL_MODULES: list[ModuleDefinition] = discover_modules()
|
||||
|
||||
__all__ = ["ALL_MODULES", "discover_modules"]
|
||||
Reference in New Issue
Block a user