File size: 5,962 Bytes
642c18b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
์‹œ์Šคํ…œ ์„ค์ • ๊ฒ€์ฆ ์Šคํฌ๋ฆฝํŠธ
์‹ค์ œ ์‹คํ–‰ ์ „์— ๋ชจ๋“  ๊ตฌ์„ฑ ์š”์†Œ๊ฐ€ ์˜ฌ๋ฐ”๋ฅธ์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.
"""

import sys
from pathlib import Path
import os

# ํ”„๋กœ์ ํŠธ ๋ฃจํŠธ๋ฅผ Python ๊ฒฝ๋กœ์— ์ถ”๊ฐ€
project_root = Path(__file__).parent.parent
sys.path.insert(0, str(project_root))

def check_file_structure():
    """ํŒŒ์ผ ๊ตฌ์กฐ ํ™•์ธ"""
    print("=" * 80)
    print("1๏ธโƒฃ ํŒŒ์ผ ๊ตฌ์กฐ ๊ฒ€์ฆ")
    print("=" * 80)

    required_files = [
        "app/main.py",
        "app/metacognitive_agent.py",
        "app/rag_pipeline.py",
        "app/api/routes.py",
        "app/api/models.py",
        "services/pdf_processor.py",
        "services/chunker.py",
        "services/embedder.py",
        "services/vector_store.py",
        "utils/config.py",
        "scripts/index_pdfs.py",
        "requirements.txt",
        ".env.example"
    ]

    missing = []
    for file in required_files:
        filepath = project_root / file
        if filepath.exists():
            print(f"โœ… {file}")
        else:
            print(f"โŒ {file} - ๋ˆ„๋ฝ!")
            missing.append(file)

    if missing:
        print(f"\nโš ๏ธ {len(missing)}๊ฐœ ํŒŒ์ผ ๋ˆ„๋ฝ")
        return False
    else:
        print(f"\nโœ… ๋ชจ๋“  ํ•„์ˆ˜ ํŒŒ์ผ ์กด์žฌ ({len(required_files)}๊ฐœ)")
        return True

def check_env_file():
    """ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ํŒŒ์ผ ํ™•์ธ"""
    print("\n" + "=" * 80)
    print("2๏ธโƒฃ ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ๊ฒ€์ฆ")
    print("=" * 80)

    env_file = project_root / ".env"
    env_example = project_root / ".env.example"

    if not env_file.exists():
        print("โš ๏ธ .env ํŒŒ์ผ์ด ์—†์Šต๋‹ˆ๋‹ค")
        print("   cp .env.example .env ๋ฅผ ์‹คํ–‰ํ•˜์„ธ์š”")
        return False

    print("โœ… .env ํŒŒ์ผ ์กด์žฌ")

    # .env ํŒŒ์ผ ๋‚ด์šฉ ํ™•์ธ
    with open(env_file) as f:
        content = f.read()

    required_keys = [
        "ANTHROPIC_API_KEY",
        "PDF_SOURCE_PATH",
        "CHROMA_PERSIST_DIRECTORY",
        "EMBEDDING_MODEL"
    ]

    for key in required_keys:
        if key in content:
            # ๊ฐ’์ด ์„ค์ •๋˜์—ˆ๋Š”์ง€ ํ™•์ธ
            for line in content.split('\n'):
                if line.startswith(key):
                    value = line.split('=', 1)[1].strip()
                    if value and not value.startswith('your_'):
                        print(f"โœ… {key}: ์„ค์ •๋จ")
                    else:
                        print(f"โš ๏ธ {key}: ๊ฐ’ ํ•„์š”")
        else:
            print(f"โŒ {key}: ๋ˆ„๋ฝ")

    return True

def check_code_syntax():
    """Python ์ฝ”๋“œ ๊ตฌ๋ฌธ ๊ฒ€์ฆ"""
    print("\n" + "=" * 80)
    print("3๏ธโƒฃ Python ์ฝ”๋“œ ๊ตฌ๋ฌธ ๊ฒ€์ฆ")
    print("=" * 80)

    python_files = list(project_root.glob("**/*.py"))
    errors = []

    for py_file in python_files:
        if 'venv' in str(py_file) or '__pycache__' in str(py_file):
            continue

        try:
            with open(py_file) as f:
                compile(f.read(), str(py_file), 'exec')
            print(f"โœ… {py_file.relative_to(project_root)}")
        except SyntaxError as e:
            print(f"โŒ {py_file.relative_to(project_root)}: {e}")
            errors.append((py_file, e))

    if errors:
        print(f"\nโŒ {len(errors)}๊ฐœ ํŒŒ์ผ์— ๊ตฌ๋ฌธ ์˜ค๋ฅ˜")
        return False
    else:
        print(f"\nโœ… ๋ชจ๋“  Python ํŒŒ์ผ ๊ตฌ๋ฌธ ์ •์ƒ ({len(python_files)}๊ฐœ)")
        return True

def check_directories():
    """ํ•„์ˆ˜ ๋””๋ ‰ํ† ๋ฆฌ ํ™•์ธ"""
    print("\n" + "=" * 80)
    print("4๏ธโƒฃ ๋””๋ ‰ํ† ๋ฆฌ ๊ตฌ์กฐ ๊ฒ€์ฆ")
    print("=" * 80)

    required_dirs = [
        "app",
        "app/api",
        "services",
        "utils",
        "scripts",
        "data"
    ]

    for dir_name in required_dirs:
        dir_path = project_root / dir_name
        if dir_path.exists() and dir_path.is_dir():
            print(f"โœ… {dir_name}/")
        else:
            print(f"โŒ {dir_name}/ - ๋ˆ„๋ฝ!")
            return False

    print(f"\nโœ… ๋ชจ๋“  ๋””๋ ‰ํ† ๋ฆฌ ์กด์žฌ")
    return True

def check_shell_scripts():
    """Shell ์Šคํฌ๋ฆฝํŠธ ํ™•์ธ"""
    print("\n" + "=" * 80)
    print("5๏ธโƒฃ Shell ์Šคํฌ๋ฆฝํŠธ ๊ฒ€์ฆ")
    print("=" * 80)

    scripts = [
        "setup.sh",
        "run_indexing.sh",
        "run_server.sh",
        "upload_to_github.sh"
    ]

    for script in scripts:
        script_path = project_root / script
        if script_path.exists():
            # ์‹คํ–‰ ๊ถŒํ•œ ํ™•์ธ
            if os.access(script_path, os.X_OK):
                print(f"โœ… {script} (์‹คํ–‰ ๊ฐ€๋Šฅ)")
            else:
                print(f"โš ๏ธ {script} (์‹คํ–‰ ๊ถŒํ•œ ์—†์Œ)")
        else:
            print(f"โŒ {script} - ๋ˆ„๋ฝ!")

    return True

def main():
    """์ „์ฒด ๊ฒ€์ฆ ์‹คํ–‰"""
    print("\n")
    print("โ•”" + "=" * 78 + "โ•—")
    print("โ•‘" + " " * 20 + "์‹œ์Šคํ…œ ์„ค์ • ๊ฒ€์ฆ" + " " * 43 + "โ•‘")
    print("โ•š" + "=" * 78 + "โ•")
    print()

    results = []

    results.append(("ํŒŒ์ผ ๊ตฌ์กฐ", check_file_structure()))
    results.append(("ํ™˜๊ฒฝ ๋ณ€์ˆ˜", check_env_file()))
    results.append(("์ฝ”๋“œ ๊ตฌ๋ฌธ", check_code_syntax()))
    results.append(("๋””๋ ‰ํ† ๋ฆฌ", check_directories()))
    results.append(("Shell ์Šคํฌ๋ฆฝํŠธ", check_shell_scripts()))

    # ์ตœ์ข… ๊ฒฐ๊ณผ
    print("\n" + "=" * 80)
    print("๐Ÿ“Š ๊ฒ€์ฆ ๊ฒฐ๊ณผ")
    print("=" * 80)

    for name, result in results:
        status = "โœ… ํ†ต๊ณผ" if result else "โŒ ์‹คํŒจ"
        print(f"{name:15} : {status}")

    all_passed = all(result for _, result in results)

    print("=" * 80)
    if all_passed:
        print("โœ… ๋ชจ๋“  ๊ฒ€์ฆ ํ†ต๊ณผ!")
        print("\n๋‹ค์Œ ๋‹จ๊ณ„:")
        print("1. .env ํŒŒ์ผ์— API ํ‚ค ์ž…๋ ฅ")
        print("2. ./run_indexing.sh ์‹คํ–‰ (PDF ์ธ๋ฑ์‹ฑ)")
        print("3. ./run_server.sh ์‹คํ–‰ (API ์„œ๋ฒ„)")
    else:
        print("โŒ ์ผ๋ถ€ ๊ฒ€์ฆ ์‹คํŒจ")
        print("์œ„์˜ ์˜ค๋ฅ˜๋ฅผ ์ˆ˜์ •ํ•˜์„ธ์š”.")
    print("=" * 80)

if __name__ == "__main__":
    main()