-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_project.py
More file actions
134 lines (107 loc) · 3.06 KB
/
Copy pathcheck_project.py
File metadata and controls
134 lines (107 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
"""
项目完整性检查脚本
检查所有必要文件是否存在
"""
import os
from pathlib import Path
from typing import List, Tuple
# 定义需要检查的文件
REQUIRED_FILES = [
# 根目录文件
"README.md",
"LICENSE",
".gitignore",
"main.py",
"setup.py",
"pyproject.toml",
"QUICKSTART.md",
"CONTRIBUTING.md",
"CHANGELOG.md",
"PROJECT_STRUCTURE.md",
"PROJECT_SUMMARY.md",
"Makefile",
"run.sh",
"run.bat",
# 依赖文件
"requirements.txt",
"requirements-mlx.txt",
"requirements-cuda.txt",
# 配置文件
"config/config.yaml",
# 源代码
"src/__init__.py",
"src/inference/__init__.py",
"src/inference/pytorch_inference.py",
"src/inference/mlx_inference.py",
"src/utils/__init__.py",
"src/utils/device_manager.py",
"src/utils/config_manager.py",
"src/models/__init__.py",
# 文档
"docs/installation.md",
"docs/model_guide.md",
"docs/usage.md",
# 示例
"examples/__init__.py",
"examples/basic_chat.py",
"examples/code_assistant.py",
"examples/batch_processing.py",
# 测试
"tests/__init__.py",
"tests/test_device_manager.py",
"tests/test_config_manager.py",
]
def check_file(filepath: str) -> Tuple[bool, str]:
"""检查文件是否存在"""
path = Path(filepath)
if path.exists():
size = path.stat().st_size
return True, f"✅ {filepath} ({size} bytes)"
else:
return False, f"❌ {filepath} (缺失)"
def check_project_structure() -> Tuple[int, int, List[str]]:
"""检查项目结构"""
total = len(REQUIRED_FILES)
passed = 0
messages = []
for filepath in REQUIRED_FILES:
exists, message = check_file(filepath)
messages.append(message)
if exists:
passed += 1
return passed, total, messages
def print_summary(passed: int, total: int, messages: List[str]):
"""打印检查结果摘要"""
print("=" * 70)
print("📦 LLM-Local 项目完整性检查")
print("=" * 70)
print()
for message in messages:
print(message)
print()
print("=" * 70)
print(f"检查结果: {passed}/{total} 文件存在")
if passed == total:
print("🎉 恭喜!所有必要文件都已创建!")
print()
print("下一步:")
print(" 1. 运行 './run.sh' 或 'python main.py --info' 检查环境")
print(" 2. 查看 QUICKSTART.md 快速开始")
print(" 3. 阅读 README.md 了解项目详情")
else:
missing = total - passed
print(f"⚠️ 有 {missing} 个文件缺失,请检查!")
print("=" * 70)
def main():
"""主函数"""
# 切换到项目根目录
project_root = Path(__file__).parent
os.chdir(project_root)
# 执行检查
passed, total, messages = check_project_structure()
# 打印结果
print_summary(passed, total, messages)
# 返回状态码
return 0 if passed == total else 1
if __name__ == "__main__":
exit(main())