File size: 3,531 Bytes
77a06d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/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())