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

66 lines
1.9 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
import os
import sys
import logging
from pathlib import Path
logging.basicConfig(level=logging.INFO, format='%(message)s')
logger = logging.getLogger(__name__)
def test_system():
logger.info("🚀 启动系统测试...")
# 创建目录
for dir_name in ["uploads", "sample_images", "text_data"]:
Path(dir_name).mkdir(exist_ok=True)
# 测试基础模块
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
# 测试VDB连接
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("❌ 需要安装: pip install pymochow")
return False
except Exception as e:
logger.error(f"❌ VDB连接失败: {e}")
return False
# 测试系统模块
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("🎉 系统测试完成!")
logger.info("启动Web应用: python web_app_vdb_production.py")
return True
if __name__ == "__main__":
test_system()