fix: auto-fix code issues (cron)
- 修复重复导入/字段 - 修复异常处理 - 修复PEP8格式问题 - 添加类型注解 - 修复重复函数定义 (health_check, create_webhook_endpoint, etc) - 修复未定义名称 (SearchOperator, TenantTier, Query, Body, logger) - 修复 workflow_manager.py 的类定义重复问题 - 添加缺失的导入
This commit is contained in:
@@ -19,8 +19,7 @@ print("\n1. 测试模块导入...")
|
||||
|
||||
try:
|
||||
from multimodal_processor import (
|
||||
get_multimodal_processor, MultimodalProcessor,
|
||||
VideoProcessingResult, VideoFrame
|
||||
get_multimodal_processor
|
||||
)
|
||||
print(" ✓ multimodal_processor 导入成功")
|
||||
except ImportError as e:
|
||||
@@ -28,8 +27,7 @@ except ImportError as e:
|
||||
|
||||
try:
|
||||
from image_processor import (
|
||||
get_image_processor, ImageProcessor,
|
||||
ImageProcessingResult, ImageEntity, ImageRelation
|
||||
get_image_processor
|
||||
)
|
||||
print(" ✓ image_processor 导入成功")
|
||||
except ImportError as e:
|
||||
@@ -37,8 +35,7 @@ except ImportError as e:
|
||||
|
||||
try:
|
||||
from multimodal_entity_linker import (
|
||||
get_multimodal_entity_linker, MultimodalEntityLinker,
|
||||
MultimodalEntity, EntityLink, AlignmentResult, FusionResult
|
||||
get_multimodal_entity_linker
|
||||
)
|
||||
print(" ✓ multimodal_entity_linker 导入成功")
|
||||
except ImportError as e:
|
||||
@@ -74,21 +71,21 @@ print("\n3. 测试实体关联功能...")
|
||||
|
||||
try:
|
||||
linker = get_multimodal_entity_linker()
|
||||
|
||||
|
||||
# 测试字符串相似度
|
||||
sim = linker.calculate_string_similarity("Project Alpha", "Project Alpha")
|
||||
assert sim == 1.0, "完全匹配应该返回1.0"
|
||||
print(f" ✓ 字符串相似度计算正常 (完全匹配: {sim})")
|
||||
|
||||
|
||||
sim = linker.calculate_string_similarity("K8s", "Kubernetes")
|
||||
print(f" ✓ 字符串相似度计算正常 (不同字符串: {sim:.2f})")
|
||||
|
||||
|
||||
# 测试实体相似度
|
||||
entity1 = {"name": "Project Alpha", "type": "PROJECT", "definition": "核心项目"}
|
||||
entity2 = {"name": "Project Alpha", "type": "PROJECT", "definition": "主要项目"}
|
||||
sim, match_type = linker.calculate_entity_similarity(entity1, entity2)
|
||||
print(f" ✓ 实体相似度计算正常 (相似度: {sim:.2f}, 类型: {match_type})")
|
||||
|
||||
|
||||
except Exception as e:
|
||||
print(f" ✗ 实体关联功能测试失败: {e}")
|
||||
|
||||
@@ -97,11 +94,11 @@ print("\n4. 测试图片处理器功能...")
|
||||
|
||||
try:
|
||||
processor = get_image_processor()
|
||||
|
||||
|
||||
# 测试图片类型检测(使用模拟数据)
|
||||
print(f" ✓ 支持的图片类型: {list(processor.IMAGE_TYPES.keys())}")
|
||||
print(f" ✓ 图片类型描述: {processor.IMAGE_TYPES}")
|
||||
|
||||
|
||||
except Exception as e:
|
||||
print(f" ✗ 图片处理器功能测试失败: {e}")
|
||||
|
||||
@@ -110,11 +107,11 @@ print("\n5. 测试视频处理器配置...")
|
||||
|
||||
try:
|
||||
processor = get_multimodal_processor()
|
||||
|
||||
|
||||
print(f" ✓ 视频目录: {processor.video_dir}")
|
||||
print(f" ✓ 帧目录: {processor.frames_dir}")
|
||||
print(f" ✓ 音频目录: {processor.audio_dir}")
|
||||
|
||||
|
||||
# 检查目录是否存在
|
||||
for dir_name, dir_path in [
|
||||
("视频", processor.video_dir),
|
||||
@@ -125,7 +122,7 @@ try:
|
||||
print(f" ✓ {dir_name}目录存在: {dir_path}")
|
||||
else:
|
||||
print(f" ✗ {dir_name}目录不存在: {dir_path}")
|
||||
|
||||
|
||||
except Exception as e:
|
||||
print(f" ✗ 视频处理器配置测试失败: {e}")
|
||||
|
||||
@@ -135,20 +132,20 @@ print("\n6. 测试数据库多模态方法...")
|
||||
try:
|
||||
from db_manager import get_db_manager
|
||||
db = get_db_manager()
|
||||
|
||||
|
||||
# 检查多模态表是否存在
|
||||
conn = db.get_conn()
|
||||
tables = ['videos', 'video_frames', 'images', 'multimodal_mentions', 'multimodal_entity_links']
|
||||
|
||||
|
||||
for table in tables:
|
||||
try:
|
||||
conn.execute(f"SELECT 1 FROM {table} LIMIT 1")
|
||||
print(f" ✓ 表 '{table}' 存在")
|
||||
except Exception as e:
|
||||
print(f" ✗ 表 '{table}' 不存在或无法访问: {e}")
|
||||
|
||||
|
||||
conn.close()
|
||||
|
||||
|
||||
except Exception as e:
|
||||
print(f" ✗ 数据库多模态方法测试失败: {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user