clovax-tax-chatbot / simple_config_test.py
bissal's picture
large modification
3a15ede
# simple_config_test.py - PyTorch ์—†์ด ๊ธฐ๋ณธ ์„ค์ • ํ…Œ์ŠคํŠธ
import os
import sys
def test_basic_config():
"""๊ธฐ๋ณธ ์„ค์ • ํ…Œ์ŠคํŠธ (PyTorch ์—†์ด)"""
print("๊ธฐ๋ณธ ์„ค์ • ํ…Œ์ŠคํŠธ")
print("=" * 30)
try:
# ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ํ™•์ธ
space_id = os.getenv('SPACE_ID')
print(f"SPACE_ID: {space_id}")
print(f"ํ—ˆ๊น…ํŽ˜์ด์Šค ํ™˜๊ฒฝ: {space_id is not None}")
# config ๋ชจ๋“ˆ ํ…Œ์ŠคํŠธ
from config import RAG_CONFIG, IS_HUGGINGFACE_SPACE
print(f"๋กœ์ปฌ/ํ—ˆ๊น…ํŽ˜์ด์Šค ๊ฐ์ง€: {IS_HUGGINGFACE_SPACE}")
print(f"์„ค์ •๋œ ์ž„๋ฒ ๋”ฉ ๋ชจ๋ธ: {RAG_CONFIG['embedding_models'][0]}")
print(f"๋ฐฐ์น˜ ํฌ๊ธฐ: {RAG_CONFIG['batch_size']}")
print(f"Top-K: {RAG_CONFIG['top_k']}")
return True
except Exception as e:
print(f"์„ค์ • ํ…Œ์ŠคํŠธ ์‹คํŒจ: {e}")
return False
def test_other_imports():
"""PyTorch ์ œ์™ธํ•œ ๋‹ค๋ฅธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํ…Œ์ŠคํŠธ"""
print("\n๋‹ค๋ฅธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ import ํ…Œ์ŠคํŠธ")
print("=" * 30)
try:
import numpy as np
print(f"โœ“ NumPy {np.__version__}")
import sklearn
print(f"โœ“ scikit-learn {sklearn.__version__}")
import requests
print("โœ“ requests ์‚ฌ์šฉ ๊ฐ€๋Šฅ")
# ๋กœ์ปฌ ๋ชจ๋“ˆ ํ…Œ์ŠคํŠธ
import config
print("โœ“ config.py ๋กœ๋“œ ๊ฐ€๋Šฅ")
import law_fetcher
print("โœ“ law_fetcher.py ๋กœ๋“œ ๊ฐ€๋Šฅ")
return True
except Exception as e:
print(f"๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํ…Œ์ŠคํŠธ ์‹คํŒจ: {e}")
return False
def test_law_fetcher_basic():
"""๋ฒ•๋ น ํŽ˜์ฒ˜ ๊ธฐ๋ณธ ํ…Œ์ŠคํŠธ"""
print("\n๋ฒ•๋ น ํŽ˜์ฒ˜ ๊ธฐ๋ณธ ํ…Œ์ŠคํŠธ")
print("=" * 30)
try:
from law_fetcher import HFLawAPIFetcher
fetcher = HFLawAPIFetcher()
print("โœ“ ๋ฒ•๋ น ํŽ˜์ฒ˜ ์ดˆ๊ธฐํ™” ์„ฑ๊ณต")
print(f" ์บ์‹œ ๋””๋ ‰ํ† ๋ฆฌ: {fetcher.cache_dir}")
print(f" ์บ์‹œ ์ •๋ณด: {len(fetcher.cache_info)}๊ฐœ")
# ์บ์‹œ ์ƒํƒœ ํ™•์ธ
if fetcher.cache_info:
for law_name in fetcher.cache_info.keys():
print(f" - ์บ์‹œ๋œ ๋ฒ•๋ น: {law_name}")
return True
except Exception as e:
print(f"๋ฒ•๋ น ํŽ˜์ฒ˜ ํ…Œ์ŠคํŠธ ์‹คํŒจ: {e}")
return False
def main():
"""๋ฉ”์ธ ํ…Œ์ŠคํŠธ ์‹คํ–‰"""
print("PyTorch ์—†์ด ๊ธฐ๋ณธ ์‹œ์Šคํ…œ ํ…Œ์ŠคํŠธ")
print("=" * 50)
tests = [
("๊ธฐ๋ณธ ์„ค์ •", test_basic_config),
("๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ Import", test_other_imports),
("๋ฒ•๋ น ํŽ˜์ฒ˜", test_law_fetcher_basic)
]
success_count = 0
for test_name, test_func in tests:
try:
if test_func():
success_count += 1
print(f"โœ“ {test_name} ์„ฑ๊ณต")
else:
print(f"โœ— {test_name} ์‹คํŒจ")
except Exception as e:
print(f"โœ— {test_name} ์˜ค๋ฅ˜: {e}")
print("\n" + "=" * 50)
print(f"๊ฒฐ๊ณผ: {success_count}/{len(tests)} ํ…Œ์ŠคํŠธ ํ†ต๊ณผ")
if success_count >= 2:
print("โœ“ ๊ธฐ๋ณธ ์‹œ์Šคํ…œ ์ •์ƒ - PyTorch ๋ฌธ์ œ๋งŒ ํ•ด๊ฒฐํ•˜๋ฉด ๋จ")
print("โœ“ ํ—ˆ๊น…ํŽ˜์ด์Šค ๋ฐฐํฌ๋Š” ๊ฐ€๋Šฅํ•œ ์ƒํƒœ")
return success_count >= 2
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)