Spaces:
Sleeping
Sleeping
| """ | |
| ์์คํ ์ค์ ๊ฒ์ฆ ์คํฌ๋ฆฝํธ | |
| ์ค์ ์คํ ์ ์ ๋ชจ๋ ๊ตฌ์ฑ ์์๊ฐ ์ฌ๋ฐ๋ฅธ์ง ํ์ธํฉ๋๋ค. | |
| """ | |
| 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() | |