DreamMachine / test_startup.py
Dave Roby
Fix model availability issues and disable Zero GPU
77a06d0
#!/usr/bin/env python3
"""
Quick startup test for DReamMachine
Tests if all modules can be loaded without crashing
"""
import os
import sys
def test_imports():
"""Test if all modules can be imported"""
print("Testing imports...")
try:
import yaml
print("βœ“ yaml imported")
except Exception as e:
print(f"βœ— yaml failed: {e}")
return False
try:
import gradio
print("βœ“ gradio imported")
except Exception as e:
print(f"βœ— gradio failed: {e}")
return False
try:
from huggingface_hub import InferenceClient
print("βœ“ huggingface_hub imported")
except Exception as e:
print(f"βœ— huggingface_hub failed: {e}")
return False
try:
from datasets import Dataset
print("βœ“ datasets imported")
except Exception as e:
print(f"βœ— datasets failed: {e}")
return False
return True
def test_config():
"""Test if config.yaml can be loaded"""
print("\nTesting config.yaml...")
try:
import yaml
with open('config.yaml', 'r') as f:
config = yaml.safe_load(f)
print("βœ“ config.yaml loaded successfully")
return True
except Exception as e:
print(f"βœ— config.yaml failed: {e}")
return False
def test_modules():
"""Test if custom modules can be imported"""
print("\nTesting custom modules...")
try:
from prompt_manager import PromptManager
print("βœ“ prompt_manager imported")
except Exception as e:
print(f"βœ— prompt_manager failed: {e}")
return False
try:
from llm_agent import LLMAgent
print("βœ“ llm_agent imported")
except Exception as e:
print(f"βœ— llm_agent failed: {e}")
return False
try:
from data_logger import DataLogger
print("βœ“ data_logger imported")
except Exception as e:
print(f"βœ— data_logger failed: {e}")
return False
try:
from orchestrator import DreamOrchestrator
print("βœ“ orchestrator imported")
except Exception as e:
print(f"βœ— orchestrator failed: {e}")
return False
return True
def test_hf_token():
"""Test if HF_TOKEN is set"""
print("\nTesting HF_TOKEN...")
token = os.getenv('HF_TOKEN')
if token:
print(f"βœ“ HF_TOKEN is set (length: {len(token)})")
return True
else:
print("βœ— HF_TOKEN is NOT set")
print(" Set it with: export HF_TOKEN=your_token_here")
return False
def main():
"""Run all tests"""
print("=" * 60)
print("DReamMachine Startup Test")
print("=" * 60)
results = []
results.append(("Imports", test_imports()))
results.append(("Config", test_config()))
results.append(("Modules", test_modules()))
results.append(("HF Token", test_hf_token()))
print("\n" + "=" * 60)
print("Test Results:")
print("=" * 60)
for name, passed in results:
status = "βœ“ PASS" if passed else "βœ— FAIL"
print(f"{status} - {name}")
all_passed = all(r[1] for r in results)
print("\n" + "=" * 60)
if all_passed:
print("βœ“ All tests passed! Ready to run DReamMachine.")
print("\nStart the app with:")
print(" python app.py")
else:
print("βœ— Some tests failed. Please fix the issues above.")
print("=" * 60)
return 0 if all_passed else 1
if __name__ == '__main__':
sys.exit(main())