-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_test.py
More file actions
95 lines (78 loc) · 2.81 KB
/
quick_test.py
File metadata and controls
95 lines (78 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# __define-ocg__ Quick Test Script
"""
Quick test script to verify basic functionality of the ML pipeline.
"""
import sys
from pathlib import Path
def test_imports():
"""Test that all modules can be imported"""
print(" Testing module imports...")
try:
from src.ingest import DataIngestion
from src.transform import DataTransformation
from src.train import ModelTrainer
from src.serialize import ModelSerializer
from src.api import app
from src.pipeline import MLPipeline
print(" All modules imported successfully")
return True
except ImportError as e:
print(f" Import failed: {e}")
return False
def test_sample_data_generation():
"""Test sample data generation"""
print("\n Testing sample data generation...")
try:
from generate_sample_data import main
main()
print(" Sample data generated successfully")
return True
except Exception as e:
print(f" Data generation failed: {e}")
return False
def test_basic_functionality():
"""Test basic functionality of core classes"""
print("\n⚙️ Testing basic functionality...")
try:
from src.ingest import DataIngestion
from src.transform import DataTransformation
# Test ingestion
ingestion = DataIngestion("data/user_logs.json")
print(f" DataIngestion initialized with varOcg={ingestion.varOcg}")
# Test transformation
transformer = DataTransformation(timeframe_days=30)
print(f" DataTransformation initialized with varOcg={transformer.varOcg}")
return True
except Exception as e:
print(f" Basic functionality test failed: {e}")
return False
def main():
"""Run all quick tests"""
print("🚀 ML Challenge Quick Test Suite")
print("=" * 40)
tests = [
("Module Imports", test_imports),
("Sample Data Generation", test_sample_data_generation),
("Basic Functionality", test_basic_functionality)
]
passed = 0
total = len(tests)
for test_name, test_func in tests:
print(f"\n {test_name}")
if test_func():
passed += 1
else:
print(f" {test_name} failed")
print("\n" + "=" * 40)
print(f" Test Results: {passed}/{total} tests passed")
if passed == total:
print("🎉 All tests passed! The ML pipeline is ready to use.")
print("\nNext steps:")
print("1. Run: python -m src.pipeline")
print("2. Start API: python -m uvicorn src.api:app --host 0.0.0.0 --port 5000")
print("3. Or use Docker: docker-compose up --build")
else:
print(" Some tests failed. Please check the errors above.")
sys.exit(1)
if __name__ == "__main__":
main()