# 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)