financial-rag-chatbot / scripts /verify_setup.py
Claude
Add system verification and sample PDF generation scripts
642c18b unverified
"""
์‹œ์Šคํ…œ ์„ค์ • ๊ฒ€์ฆ ์Šคํฌ๋ฆฝํŠธ
์‹ค์ œ ์‹คํ–‰ ์ „์— ๋ชจ๋“  ๊ตฌ์„ฑ ์š”์†Œ๊ฐ€ ์˜ฌ๋ฐ”๋ฅธ์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.
"""
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()