-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch.py
More file actions
218 lines (196 loc) ยท 8.42 KB
/
launch.py
File metadata and controls
218 lines (196 loc) ยท 8.42 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/usr/bin/env python3
"""
Quick launcher for GenAI Testing Tutorial experiments.
This script provides easy access to all testing and experiment capabilities
in the reorganized project structure.
"""
import os
import sys
import subprocess
def show_menu():
"""Show main menu."""
print("๐งช GenAI Testing Tutorial - Quick Launcher")
print("=" * 60)
print()
print("1. ๐ฌ Run Optimization Experiments")
print(" Interactive menu-driven experiments")
print()
print("2. ๐งช Run Regression Testing")
print(" Test against gold standards with quality gates")
print()
print("3. ๐ฎ Regression Testing Demo")
print(" Interactive tutorial and framework validation")
print()
print("4. ๐งโ๐ป Run Unit Tests")
print(" Traditional pytest-based testing")
print()
print("5. ๐ Run Evaluation Framework")
print(" Advanced quality assessment tools")
print()
print("6. ๐ Start Flask Application")
print(" Launch the chat interface")
print()
print("7. ๐งช Lightweight Regression Demo")
print(" Works without heavy dependencies")
print()
print("8. ๐ Open Documentation")
print(" View comprehensive guides and documentation")
print()
print("0. Exit")
print()
def run_experiments():
"""Launch optimization experiments."""
print("๐ฌ Launching Optimization Experiments...")
try:
subprocess.run([sys.executable, "-m", "experiments.run_experiments"], check=True)
except subprocess.CalledProcessError as e:
print(f"โ Error running experiments: {e}")
except FileNotFoundError:
print("โ Python not found. Make sure Python is in your PATH.")
def run_regression_testing():
"""Launch regression testing."""
print("๐งช Launching Regression Testing...")
venv_python = r"c:\Users\jpayne\Documents\Training\Notebooks for ML classes\training-env\Scripts\python.exe"
if os.path.exists(venv_python):
print("Using training-env virtual environment with tf-keras...")
try:
subprocess.run([venv_python, "-m", "regression_testing.regression_testing"], check=True)
except subprocess.CalledProcessError as e:
print(f"โ Error running regression tests: {e}")
else:
try:
subprocess.run([sys.executable, "-m", "regression_testing.regression_testing"], check=True)
except subprocess.CalledProcessError as e:
print(f"โ Error running regression tests: {e}")
except FileNotFoundError:
print("โ Python not found. Make sure Python is in your PATH.")
def run_regression_demo():
"""Launch regression testing demo."""
print("๐ฎ Launching Regression Testing Demo...")
venv_python = r"c:\Users\jpayne\Documents\Training\Notebooks for ML classes\training-env\Scripts\python.exe"
if os.path.exists(venv_python):
print("Using training-env virtual environment with tf-keras...")
try:
demo_path = os.path.join(os.path.dirname(__file__), "regression_testing", "demo_regression_testing.py")
subprocess.run([venv_python, demo_path], check=True)
except subprocess.CalledProcessError as e:
print(f"โ Error running regression demo: {e}")
else:
try:
subprocess.run([sys.executable, "-m", "regression_testing.demo_regression_testing"], check=True)
except subprocess.CalledProcessError as e:
print(f"โ Error running regression demo: {e}")
except FileNotFoundError:
print("โ Python not found. Make sure Python is in your PATH.")
def run_unit_tests():
"""Run unit tests."""
print("๐งโ๐ป Running Unit Tests...")
try:
subprocess.run([sys.executable, "-m", "pytest", "tests/test_rag_pipeline.py", "-v"], check=True)
except subprocess.CalledProcessError as e:
print(f"โ Error running unit tests: {e}")
print("Make sure pytest is installed: pip install pytest")
except FileNotFoundError:
print("โ Python not found. Make sure Python is in your PATH.")
def run_evaluation_framework():
"""Run evaluation framework."""
print("๐ Running Evaluation Framework...")
try:
subprocess.run([sys.executable, "tests/evaluation_framework.py"], check=True)
except subprocess.CalledProcessError as e:
print(f"โ Error running evaluation framework: {e}")
except FileNotFoundError:
print("โ Python not found. Make sure Python is in your PATH.")
def start_flask_app():
"""Start the Flask application."""
print("๐ Starting Flask Application...")
print("The chat interface will be available at: http://localhost:5000")
print("Press Ctrl+C to stop the server.")
try:
subprocess.run([sys.executable, "run.py"], check=True)
except subprocess.CalledProcessError as e:
print(f"โ Error starting Flask app: {e}")
except KeyboardInterrupt:
print("\n๐ Server stopped.")
except FileNotFoundError:
print("โ Python not found. Make sure Python is in your PATH.")
def run_lightweight_demo():
"""Run lightweight regression testing demo."""
print("๐งช Launching Lightweight Regression Demo...")
try:
subprocess.run([sys.executable, "lightweight_regression_demo.py"], check=True)
except subprocess.CalledProcessError as e:
print(f"โ Error running lightweight demo: {e}")
except FileNotFoundError:
print("โ Python not found. Make sure Python is in your PATH.")
def open_documentation():
"""Show documentation options."""
print("๐ Available Documentation:")
print()
print("Main documentation files:")
print("โข README.md - Main project overview (this directory)")
print("โข docs/EXPERIMENTS_README.md - Detailed experiment guide")
print("โข docs/REGRESSION_TESTING_README.md - Regression testing guide")
print("โข docs/STUDENT_GUIDE.md - Complete student tutorial")
print("โข docs/PROJECT_PLAN.md - Implementation details")
print("โข experiments/README.md - Experiments package overview")
print("โข regression_testing/README.md - Regression testing overview")
print()
print("Online documentation:")
print("โข Open any .md file in a text editor or markdown viewer")
print("โข Use VS Code or similar for best viewing experience")
# Try to open main README
doc_choice = input("Open main README.md? (y/n): ").strip().lower()
if doc_choice == 'y':
try:
if os.name == 'nt': # Windows
os.startfile("README.md")
elif os.name == 'posix': # macOS and Linux
subprocess.run(["open", "README.md"], check=True)
except Exception as e:
print(f"โ Could not open README.md automatically: {e}")
print("Please open README.md in your preferred text editor.")
def main():
"""Main launcher."""
while True:
show_menu()
try:
choice = input("Select option (0-8): ").strip()
if choice == "0":
print("๐ Happy testing! Remember to explore all the testing approaches!")
break
elif choice == "1":
run_experiments()
elif choice == "2":
run_regression_testing()
elif choice == "3":
run_regression_demo()
elif choice == "4":
run_unit_tests()
elif choice == "5":
run_evaluation_framework()
elif choice == "6":
start_flask_app()
elif choice == "7":
run_lightweight_demo()
elif choice == "8":
open_documentation()
else:
print("โ Invalid choice. Please select 0-8.")
if choice != "0" and choice != "6": # Don't pause after Flask app
input("\nPress Enter to return to menu...")
print("\n" + "="*80)
except KeyboardInterrupt:
print("\n\n๐ Launcher interrupted. Goodbye!")
break
except Exception as e:
print(f"\nโ Error: {str(e)}")
input("Press Enter to continue...")
if __name__ == "__main__":
# Change to script directory
script_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(script_dir)
print("๐ง GenAI Testing Tutorial Quick Launcher")
print("Working directory:", os.getcwd())
print()
main()