-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate_setup.py
More file actions
150 lines (119 loc) · 3.89 KB
/
validate_setup.py
File metadata and controls
150 lines (119 loc) · 3.89 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/env python3
"""
Simple validation script to check project setup without external dependencies.
"""
import os
import sys
from pathlib import Path
def check_directory_structure():
"""Check if all required directories exist."""
required_dirs = [
"fine_tuning",
"api",
"evaluator",
"web_interface",
"tests",
"config",
"utils",
]
print("Checking directory structure...")
missing_dirs = []
for directory in required_dirs:
if os.path.exists(directory) and os.path.isdir(directory):
print(f"✓ {directory}/")
else:
print(f"✗ {directory}/ (missing)")
missing_dirs.append(directory)
return len(missing_dirs) == 0
def check_required_files():
"""Check if all required files exist."""
required_files = [
"requirements.txt",
".env.example",
"main.py",
"setup.py",
"README.md",
"config/settings.py",
"utils/logging.py",
"utils/exceptions.py",
"utils/error_handler.py",
]
print("\nChecking required files...")
missing_files = []
for file_path in required_files:
if os.path.exists(file_path) and os.path.isfile(file_path):
print(f"✓ {file_path}")
else:
print(f"✗ {file_path} (missing)")
missing_files.append(file_path)
return len(missing_files) == 0
def check_python_version():
"""Check Python version compatibility."""
print(f"\nChecking Python version...")
version = sys.version_info
if version >= (3, 8):
print(f"✓ Python {version.major}.{version.minor}.{version.micro} (compatible)")
return True
else:
print(f"✗ Python {version.major}.{version.minor}.{version.micro} (requires 3.8+)")
return False
def check_requirements_file():
"""Check if requirements.txt has expected dependencies."""
print("\nChecking requirements.txt...")
if not os.path.exists("requirements.txt"):
print("✗ requirements.txt not found")
return False
expected_deps = [
"transformers",
"torch",
"flask",
"langchain",
"pydantic",
"python-dotenv",
]
try:
with open("requirements.txt", "r") as f:
content = f.read().lower()
missing_deps = []
for dep in expected_deps:
if dep.lower() in content:
print(f"✓ {dep}")
else:
print(f"✗ {dep} (missing)")
missing_deps.append(dep)
return len(missing_deps) == 0
except Exception as e:
print(f"✗ Error reading requirements.txt: {e}")
return False
def main():
"""Main validation function."""
print("🔍 Validating LLM Optimization Platform Setup")
print("=" * 50)
checks = [
("Python Version", check_python_version),
("Directory Structure", check_directory_structure),
("Required Files", check_required_files),
("Dependencies", check_requirements_file),
]
all_passed = True
for check_name, check_func in checks:
try:
result = check_func()
if not result:
all_passed = False
except Exception as e:
print(f"✗ Error in {check_name}: {e}")
all_passed = False
print("\n" + "=" * 50)
if all_passed:
print("🎉 All checks passed! Setup is complete.")
print("\nNext steps:")
print("1. Run: python setup.py")
print("2. Activate virtual environment")
print("3. Update .env file with your API keys")
print("4. Start the application: python main.py api")
else:
print("❌ Some checks failed. Please review the output above.")
sys.exit(1)
if __name__ == "__main__":
main()