|
|
|
|
|
""" |
|
|
HITL Drug Discovery Application Launcher |
|
|
|
|
|
This script launches the modular drug discovery application. |
|
|
It handles virtual environment activation and provides clear feedback. |
|
|
""" |
|
|
|
|
|
import sys |
|
|
import os |
|
|
import subprocess |
|
|
from pathlib import Path |
|
|
|
|
|
def check_virtual_env(): |
|
|
"""Check if we're in a virtual environment.""" |
|
|
return hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix) |
|
|
|
|
|
def activate_venv_and_run(): |
|
|
"""Activate virtual environment and run the application.""" |
|
|
project_dir = Path(__file__).parent |
|
|
venv_path = project_dir / "venv" |
|
|
|
|
|
if not venv_path.exists(): |
|
|
print("β Virtual environment not found!") |
|
|
print("Please run: python -m venv venv") |
|
|
print("Then: source venv/bin/activate") |
|
|
print("Finally: pip install -r requirements.txt") |
|
|
return False |
|
|
|
|
|
|
|
|
try: |
|
|
if os.name == 'nt': |
|
|
activate_script = venv_path / "Scripts" / "activate.bat" |
|
|
python_exe = venv_path / "Scripts" / "python.exe" |
|
|
else: |
|
|
activate_script = venv_path / "bin" / "activate" |
|
|
python_exe = venv_path / "bin" / "python" |
|
|
|
|
|
if python_exe.exists(): |
|
|
print("π Starting HITL Drug Discovery (Modular Version)...") |
|
|
print("π Using virtual environment:", venv_path) |
|
|
print("π Application will be available at: http://localhost:7860") |
|
|
print("βΉοΈ Press Ctrl+C to stop the application") |
|
|
print("-" * 60) |
|
|
|
|
|
|
|
|
subprocess.run([str(python_exe), "app.py"], cwd=project_dir) |
|
|
return True |
|
|
else: |
|
|
print("β Python executable not found in virtual environment!") |
|
|
return False |
|
|
|
|
|
except Exception as e: |
|
|
print(f"β Error running application: {e}") |
|
|
return False |
|
|
|
|
|
def main(): |
|
|
"""Main launcher function.""" |
|
|
print("𧬠HITL Drug Discovery Application Launcher") |
|
|
print("=" * 50) |
|
|
|
|
|
if check_virtual_env(): |
|
|
print("β
Virtual environment detected") |
|
|
print("π Starting application...") |
|
|
try: |
|
|
import app |
|
|
print("π Application available at: http://localhost:7860") |
|
|
print("βΉοΈ Press Ctrl+C to stop") |
|
|
except ImportError as e: |
|
|
print(f"β Import error: {e}") |
|
|
print("π‘ Try running: pip install -r requirements.txt") |
|
|
except Exception as e: |
|
|
print(f"β Error: {e}") |
|
|
else: |
|
|
print("β οΈ No virtual environment detected") |
|
|
print("π Attempting to activate virtual environment...") |
|
|
if not activate_venv_and_run(): |
|
|
print("\nπ‘ Manual setup required:") |
|
|
print("1. python -m venv venv") |
|
|
print("2. source venv/bin/activate # (or venv\\Scripts\\activate on Windows)") |
|
|
print("3. pip install -r requirements.txt") |
|
|
print("4. python app.py") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
main() |
|
|
|