mmeb/test_system_startup.py
2025-09-01 11:24:01 +00:00

81 lines
2.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
系统启动测试
"""
import os
import sys
import logging
from pathlib import Path
# 设置日志
logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s')
logger = logging.getLogger(__name__)
def main():
"""主测试函数"""
logger.info("🚀 启动系统测试...")
# 创建必要目录
directories = ["uploads", "sample_images", "text_data"]
for dir_name in directories:
Path(dir_name).mkdir(exist_ok=True)
logger.info(f"✅ 创建目录: {dir_name}")
# 1. 测试基础模块导入
logger.info("\n📦 测试基础模块...")
try:
import torch
import transformers
import numpy as np
from PIL import Image
import flask
logger.info("✅ 基础模块导入成功")
except Exception as e:
logger.error(f"❌ 基础模块导入失败: {e}")
return False
# 2. 测试PyMochow
logger.info("\n🔗 测试百度VDB SDK...")
try:
import pymochow
from pymochow.configuration import Configuration
from pymochow.auth.bce_credentials import BceCredentials
# 测试连接
config = Configuration(
credentials=BceCredentials("root", "vdb$yjr9ln3n0td"),
endpoint="http://180.76.96.191:5287"
)
client = pymochow.MochowClient(config)
databases = client.list_databases()
client.close()
logger.info(f"✅ VDB连接成功发现 {len(databases)} 个数据库")
except ImportError:
logger.error("❌ PyMochow未安装请运行: pip install pymochow")
return False
except Exception as e:
logger.error(f"❌ VDB连接失败: {e}")
return False
# 3. 测试系统模块
logger.info("\n🔧 测试系统模块...")
try:
from multimodal_retrieval_vdb_only import MultimodalRetrievalVDBOnly
from baidu_vdb_production import BaiduVDBProduction
logger.info("✅ 系统模块导入成功")
except Exception as e:
logger.error(f"❌ 系统模块导入失败: {e}")
return False
logger.info("\n🎉 系统测试完成!所有组件正常")
logger.info("可以启动Web应用: python web_app_vdb_production.py")
return True
if __name__ == "__main__":
success = main()
if not success:
sys.exit(1)