63 lines
1.6 KiB
Python
63 lines
1.6 KiB
Python
"""
|
|||
|
|
Convenience script to run examples with correct Python path
|
||
|
|
"""
|
||
|
|
|
||
|
|
import sys
|
||
|
|
import subprocess
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
|
||
|
|
def run_example(script_name):
|
||
|
|
"""Run an example script with correct Python path"""
|
||
|
|
|
||
|
|
# Get the rag_evaluation directory
|
||
|
|
rag_eval_dir = Path(__file__).parent
|
||
|
|
|
||
|
|
# Run the script with correct PYTHONPATH
|
||
|
|
env = dict(subprocess.os.environ)
|
||
|
|
env['PYTHONPATH'] = str(rag_eval_dir.parent)
|
||
|
|
|
||
|
|
script_path = rag_eval_dir / script_name
|
||
|
|
|
||
|
|
if not script_path.exists():
|
||
|
|
print(f"Error: {script_name} not found at {script_path}")
|
||
|
|
return 1
|
||
|
|
|
||
|
|
print(f"Running {script_name}...")
|
||
|
|
print("=" * 60)
|
||
|
|
|
||
|
|
try:
|
||
|
|
result = subprocess.run(
|
||
|
|
[sys.executable, str(script_path)],
|
||
|
|
env=env,
|
||
|
|
cwd=str(rag_eval_dir)
|
||
|
|
)
|
||
|
|
return result.returncode
|
||
|
|
except Exception as e:
|
||
|
|
print(f"Error running {script_name}: {e}")
|
||
|
|
return 1
|
||
|
|
|
||
|
|
|
||
|
|
def main():
|
||
|
|
"""Main function"""
|
||
|
|
|
||
|
|
if len(sys.argv) < 2:
|
||
|
|
print("Usage: python run.py <script_name>")
|
||
|
|
print()
|
||
|
|
print("Available scripts:")
|
||
|
|
print(" python run.py example.py # Run Phase 1 example")
|
||
|
|
print(" python run.py example_phase2.py # Run Phase 2 example")
|
||
|
|
print(" python run.py test_framework.py # Run tests")
|
||
|
|
print()
|
||
|
|
print("Or directly:")
|
||
|
|
print(" python example.py")
|
||
|
|
print(" python example_phase2.py")
|
||
|
|
print(" python test_framework.py")
|
||
|
|
return 1
|
||
|
|
|
||
|
|
script_name = sys.argv[1]
|
||
|
|
return run_example(script_name)
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
sys.exit(main())
|