File size: 7,448 Bytes
d810ed8 |
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 219 220 |
#!/usr/bin/env python3
"""
DeepCode - AI Research Engine Launcher
𧬠Next-Generation AI Research Automation Platform
β‘ Transform research papers into working code automatically
"""
import os
import sys
import subprocess
from pathlib import Path
def check_dependencies():
"""Check if necessary dependencies are installed"""
import importlib.util
print("π Checking dependencies...")
missing_deps = []
missing_system_deps = []
# Check Streamlit availability
if importlib.util.find_spec("streamlit") is not None:
print("β
Streamlit is installed")
else:
missing_deps.append("streamlit>=1.28.0")
# Check PyYAML availability
if importlib.util.find_spec("yaml") is not None:
print("β
PyYAML is installed")
else:
missing_deps.append("pyyaml")
# Check asyncio availability
if importlib.util.find_spec("asyncio") is not None:
print("β
Asyncio is available")
else:
missing_deps.append("asyncio")
# Check PDF conversion dependencies
if importlib.util.find_spec("reportlab") is not None:
print("β
ReportLab is installed (for text-to-PDF conversion)")
else:
missing_deps.append("reportlab")
print("β οΈ ReportLab not found (text files won't convert to PDF)")
# Check LibreOffice for Office document conversion
try:
import subprocess
import platform
subprocess_kwargs = {
"capture_output": True,
"text": True,
"timeout": 5,
}
if platform.system() == "Windows":
subprocess_kwargs["creationflags"] = 0x08000000 # Hide console window
# Try different LibreOffice commands
libreoffice_found = False
for cmd in ["libreoffice", "soffice"]:
try:
result = subprocess.run([cmd, "--version"], **subprocess_kwargs)
if result.returncode == 0:
print(
"β
LibreOffice is installed (for Office document conversion)"
)
libreoffice_found = True
break
except (
subprocess.CalledProcessError,
FileNotFoundError,
subprocess.TimeoutExpired,
):
continue
if not libreoffice_found:
missing_system_deps.append("LibreOffice")
print("β οΈ LibreOffice not found (Office documents won't convert to PDF)")
except Exception:
missing_system_deps.append("LibreOffice")
print("β οΈ Could not check LibreOffice installation")
# Display missing dependencies
if missing_deps or missing_system_deps:
print("\nπ Dependency Status:")
if missing_deps:
print("β Missing Python dependencies:")
for dep in missing_deps:
print(f" - {dep}")
print(f"\nInstall with: pip install {' '.join(missing_deps)}")
if missing_system_deps:
print("\nβ οΈ Missing system dependencies (optional for full functionality):")
for dep in missing_system_deps:
print(f" - {dep}")
print("\nInstall LibreOffice:")
print(" - Windows: Download from https://www.libreoffice.org/")
print(" - macOS: brew install --cask libreoffice")
print(" - Ubuntu/Debian: sudo apt-get install libreoffice")
# Only fail if critical Python dependencies are missing
if missing_deps:
return False
else:
print("\nβ
Core dependencies satisfied (optional dependencies missing)")
else:
print("β
All dependencies satisfied")
return True
def cleanup_cache():
"""Clean up Python cache files"""
try:
print("π§Ή Cleaning up cache files...")
# Clean up __pycache__ directories
os.system('find . -type d -name "__pycache__" -exec rm -r {} + 2>/dev/null')
# Clean up .pyc files
os.system('find . -name "*.pyc" -delete 2>/dev/null')
print("β
Cache cleanup completed")
except Exception as e:
print(f"β οΈ Cache cleanup failed: {e}")
def print_banner():
"""Display startup banner"""
banner = """
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β 𧬠DeepCode - AI Research Engine β
β β
β β‘ NEURAL β’ AUTONOMOUS β’ REVOLUTIONARY β‘ β
β β
β Transform research papers into working code β
β Next-generation AI automation platform β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
"""
print(banner)
def main():
"""Main function"""
print_banner()
# Check dependencies
if not check_dependencies():
print("\nπ¨ Please install missing dependencies and try again.")
sys.exit(1)
# Get current script directory
current_dir = Path(__file__).parent
streamlit_app_path = current_dir / "ui" / "streamlit_app.py"
# Check if streamlit_app.py exists
if not streamlit_app_path.exists():
print(f"β UI application file not found: {streamlit_app_path}")
print("Please ensure the ui/streamlit_app.py file exists.")
sys.exit(1)
print(f"\nπ UI App location: {streamlit_app_path}")
print("π Starting DeepCode web interface...")
print("π Launching on http://localhost:8501")
print("=" * 70)
print("π‘ Tip: Keep this terminal open while using the application")
print("π Press Ctrl+C to stop the server")
print("=" * 70)
# Launch Streamlit application
try:
cmd = [
sys.executable,
"-m",
"streamlit",
"run",
str(streamlit_app_path),
"--server.port",
"8501",
"--server.address",
"localhost",
"--browser.gatherUsageStats",
"false",
"--theme.base",
"dark",
"--theme.primaryColor",
"#3b82f6",
"--theme.backgroundColor",
"#0f1419",
"--theme.secondaryBackgroundColor",
"#1e293b",
]
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
print(f"\nβ Failed to start DeepCode: {e}")
print("Please check if Streamlit is properly installed.")
sys.exit(1)
except KeyboardInterrupt:
print("\n\nπ DeepCode server stopped by user")
print("Thank you for using DeepCode! π§¬")
except Exception as e:
print(f"\nβ Unexpected error: {e}")
print("Please check your Python environment and try again.")
sys.exit(1)
finally:
# Clean up cache files
cleanup_cache()
if __name__ == "__main__":
main()
|