Spaces:
Paused
Paused
| # 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) |