Spaces:
Running
Running
File size: 5,138 Bytes
0913c52 |
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 |
#!/usr/bin/env python3
"""
Test Setup Script for SciEvo Streamlit Interface
This script validates that all dependencies and configurations are correct.
"""
import sys
from pathlib import Path
# Add parent directory to path
sys.path.insert(0, str(Path(__file__).parent.parent))
def test_imports():
"""Test that all required imports work."""
print("π Testing imports...")
try:
import streamlit as st
print(" β
Streamlit imported successfully")
except ImportError as e:
print(f" β Streamlit import failed: {e}")
print(" Fix: pip install streamlit")
return False
try:
from scievo.workflows.full_workflow_with_ideation import FullWorkflowWithIdeation
print(" β
SciEvo workflow imported successfully")
except ImportError as e:
print(f" β SciEvo import failed: {e}")
print(" Fix: Ensure parent directory is set up correctly")
return False
try:
from scievo.core.brain import Brain
from scievo.core.llms import ModelRegistry
print(" β
SciEvo core modules imported successfully")
except ImportError as e:
print(f" β SciEvo core import failed: {e}")
return False
return True
def test_env_file():
"""Test that .env file exists and has required keys."""
print("\nπ Testing environment configuration...")
env_path = Path(__file__).parent.parent / ".env"
if not env_path.exists():
print(f" β οΈ .env file not found at {env_path}")
print(" Recommendation: Copy .env.template to .env and add your API keys")
return False
# Read .env and check for API keys
env_content = env_path.read_text()
required_keys = ["OPENAI_API_KEY", "GEMINI_API_KEY"]
found_keys = []
for key in required_keys:
if key in env_content:
# Check if it's not just a placeholder
for line in env_content.split("\n"):
if line.startswith(key) and "..." not in line and "your_" not in line.lower():
found_keys.append(key)
break
if len(found_keys) == len(required_keys):
print(f" β
All required API keys found")
return True
else:
missing = set(required_keys) - set(found_keys)
print(f" β οΈ Missing or incomplete API keys: {missing}")
print(f" Found: {found_keys}")
return False
def test_directories():
"""Test that required directories exist."""
print("\nπ Testing directory structure...")
parent_dir = Path(__file__).parent.parent
required_dirs = ["scievo", "scievo/workflows", "scievo/agents", "scievo/tools"]
all_exist = True
for dir_name in required_dirs:
dir_path = parent_dir / dir_name
if dir_path.exists():
print(f" β
{dir_name} exists")
else:
print(f" β {dir_name} not found")
all_exist = False
return all_exist
def test_streamlit_files():
"""Test that streamlit client files exist."""
print("\nπ Testing Streamlit client files...")
client_dir = Path(__file__).parent
required_files = [
"app.py",
"app_enhanced.py",
"display_components.py",
"workflow_monitor.py",
"requirements.txt",
"README.md",
]
all_exist = True
for file_name in required_files:
file_path = client_dir / file_name
if file_path.exists():
print(f" β
{file_name} exists")
else:
print(f" β {file_name} not found")
all_exist = False
return all_exist
def main():
"""Run all tests."""
print("=" * 60)
print("SciEvo Streamlit Interface - Setup Validation")
print("=" * 60)
tests = [
("Import Test", test_imports),
("Environment Test", test_env_file),
("Directory Structure Test", test_directories),
("Streamlit Files Test", test_streamlit_files),
]
results = {}
for test_name, test_func in tests:
try:
results[test_name] = test_func()
except Exception as e:
print(f"\nβ {test_name} failed with exception: {e}")
results[test_name] = False
# Summary
print("\n" + "=" * 60)
print("SUMMARY")
print("=" * 60)
passed = sum(1 for v in results.values() if v)
total = len(results)
for test_name, result in results.items():
status = "β
PASS" if result else "β FAIL"
print(f"{status:12} {test_name}")
print("\n" + f"Results: {passed}/{total} tests passed")
if passed == total:
print("\nπ All tests passed! You're ready to run the Streamlit interface.")
print("\nRun the interface with:")
print(" ./run.sh (Linux/Mac)")
print(" run.bat (Windows)")
print(" streamlit run app_enhanced.py (Direct)")
return 0
else:
print("\nβ οΈ Some tests failed. Please fix the issues above before running the interface.")
return 1
if __name__ == "__main__":
sys.exit(main())
|