Spaces:
Sleeping
Sleeping
Download validate_implementation.py from MikeZhang09/marketwise: direct link, hf CLI and curl.
- Browser
- Download file 2.81 kB
-
https://huggingface.co/spaces/MikeZhang09/marketwise/resolve/main/validate_implementation.py
- Command line
-
hf download hf://spaces/MikeZhang09/marketwise/validate_implementation.py
-
curl -L -o validate_implementation.py https://huggingface.co/spaces/MikeZhang09/marketwise/resolve/main/validate_implementation.py
2.81 kB
| #!/usr/bin/env python3 | |
| """ | |
| Simple validation script to test our implementation structure. | |
| """ | |
| def test_config(): | |
| """Test configuration loading.""" | |
| try: | |
| from src.utils.config import Config | |
| config = Config() | |
| indices = config.get_indices() | |
| print(f"β Config loaded successfully with {len(indices['indices'])} indices") | |
| return True | |
| except Exception as e: | |
| print(f"β Config test failed: {e}") | |
| return False | |
| def test_models(): | |
| """Test model definitions.""" | |
| try: | |
| from src.data.models import MarketData, Base | |
| print("β Models imported successfully") | |
| print(f"β MarketData table: {MarketData.__tablename__}") | |
| return True | |
| except Exception as e: | |
| print(f"β Models test failed: {e}") | |
| return False | |
| def test_file_structure(): | |
| """Test file structure.""" | |
| import os | |
| required_files = [ | |
| 'src/data/__init__.py', | |
| 'src/data/models.py', | |
| 'src/data/database.py', | |
| 'src/data/fetcher.py', | |
| 'src/data/storage.py', | |
| 'src/utils/__init__.py', | |
| 'src/utils/config.py', | |
| 'config/indices.json', | |
| 'requirements.txt' | |
| ] | |
| missing_files = [] | |
| for file_path in required_files: | |
| if not os.path.exists(file_path): | |
| missing_files.append(file_path) | |
| if missing_files: | |
| print(f"β Missing files: {missing_files}") | |
| return False | |
| else: | |
| print("β All required files present") | |
| return True | |
| def test_syntax(): | |
| """Test Python syntax.""" | |
| import py_compile | |
| import glob | |
| python_files = glob.glob('src/**/*.py', recursive=True) | |
| for file_path in python_files: | |
| try: | |
| py_compile.compile(file_path, doraise=True) | |
| except py_compile.PyCompileError as e: | |
| print(f"β Syntax error in {file_path}: {e}") | |
| return False | |
| print(f"β Syntax check passed for {len(python_files)} Python files") | |
| return True | |
| def main(): | |
| """Run all validation tests.""" | |
| print("Running MarketWise validation tests...") | |
| print("=" * 50) | |
| tests = [ | |
| ("File Structure", test_file_structure), | |
| ("Python Syntax", test_syntax), | |
| ("Configuration", test_config), | |
| ("Models", test_models), | |
| ] | |
| passed = 0 | |
| total = len(tests) | |
| for test_name, test_func in tests: | |
| print(f"\n{test_name}:") | |
| if test_func(): | |
| passed += 1 | |
| print("\n" + "=" * 50) | |
| print(f"Validation Results: {passed}/{total} tests passed") | |
| if passed == total: | |
| print("π All validation tests passed!") | |
| return True | |
| else: | |
| print("β Some validation tests failed") | |
| return False | |
| if __name__ == "__main__": | |
| main() | |