fix: auto-fix code issues (cron)

- 修复重复导入/字段
- 修复异常处理
- 修复PEP8格式问题 (E302, E305, E501)
- 修复行长度超过100字符的问题
- 修复F821未定义名称错误
This commit is contained in:
AutoFix Bot
2026-03-01 18:19:06 +08:00
parent 8f59c7b17c
commit e46c938b40
36 changed files with 1102 additions and 28 deletions

View File

@@ -13,6 +13,7 @@ from ai_manager import ModelType, PredictionType, get_ai_manager
# Add backend directory to path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
def test_custom_model():
"""测试自定义模型功能"""
print("\n=== 测试自定义模型 ===")
@@ -87,6 +88,7 @@ def test_custom_model():
return model.id
async def test_train_and_predict(model_id: str):
"""测试训练和预测"""
print("\n=== 测试模型训练和预测 ===")
@@ -113,6 +115,7 @@ async def test_train_and_predict(model_id: str):
except Exception as e:
print(f" 预测失败: {e}")
def test_prediction_models():
"""测试预测模型"""
print("\n=== 测试预测模型 ===")
@@ -154,6 +157,7 @@ def test_prediction_models():
return trend_model.id, anomaly_model.id
async def test_predictions(trend_model_id: str, anomaly_model_id: str):
"""测试预测功能"""
print("\n=== 测试预测功能 ===")
@@ -188,6 +192,7 @@ async def test_predictions(trend_model_id: str, anomaly_model_id: str):
)
print(f" 检测结果: {anomaly_result.prediction_data}")
def test_kg_rag():
"""测试知识图谱 RAG"""
print("\n=== 测试知识图谱 RAG ===")
@@ -217,6 +222,7 @@ def test_kg_rag():
return rag.id
async def test_kg_rag_query(rag_id: str):
"""测试 RAG 查询"""
print("\n=== 测试知识图谱 RAG 查询 ===")
@@ -287,6 +293,7 @@ async def test_kg_rag_query(rag_id: str):
except Exception as e:
print(f" 查询失败: {e}")
async def test_smart_summary():
"""测试智能摘要"""
print("\n=== 测试智能摘要 ===")
@@ -334,6 +341,7 @@ async def test_smart_summary():
except Exception as e:
print(f" 生成失败: {e}")
async def main():
"""主测试函数"""
print("=" * 60)