Skip to content

Commit 460f8f3

Browse files
committed
add test
1 parent 33baf56 commit 460f8f3

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Test script to demonstrate the complete parameter coverage documentation workflow.
4+
5+
This script shows how to:
6+
1. Generate sample data for ML functions
7+
2. Create parameter coverage documentation
8+
3. Verify the documentation updates automatically
9+
"""
10+
11+
import os
12+
import sys
13+
import tempfile
14+
import shutil
15+
16+
# Add the src directory to Python path
17+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
18+
19+
from surfaces.test_functions.machine_learning.tabular.regression.test_functions.k_neighbors_regressor import KNeighborsRegressorFunction
20+
21+
22+
def test_workflow():
23+
"""Test the complete workflow."""
24+
print("🧪 Testing ML Parameter Coverage Documentation Workflow")
25+
print("=" * 60)
26+
27+
# Test 1: Generate documentation with no data
28+
print("\n1. Testing documentation generation with no/minimal data...")
29+
os.system("python generate_parameter_coverage_docs.py -f k_neighbors_regressor")
30+
31+
# Test 2: Generate some sample data
32+
print("\n2. Generating sample search data...")
33+
34+
# Create a function instance and collect a small amount of data
35+
func = KNeighborsRegressorFunction()
36+
37+
# Use a smaller search space for testing
38+
custom_search_space = {
39+
'n_neighbors': [3, 5, 7],
40+
'algorithm': ['auto', 'ball_tree'],
41+
'cv': [2, 3],
42+
'dataset': func.search_space()['dataset'][:1] # Just one dataset
43+
}
44+
45+
print(f"Collecting data with custom search space: {custom_search_space}")
46+
print("(This will take a moment as it actually trains ML models...)")
47+
48+
try:
49+
stats = func.collect_search_data(
50+
search_space=custom_search_space,
51+
batch_size=5,
52+
verbose=True
53+
)
54+
print(f"✅ Data collection completed: {stats['evaluations_collected']} new evaluations")
55+
except Exception as e:
56+
print(f"⚠️ Data collection failed: {e}")
57+
print("This is normal if scikit-learn datasets are not available")
58+
59+
# Test 3: Generate updated documentation
60+
print("\n3. Generating updated documentation...")
61+
os.system("python generate_parameter_coverage_docs.py -f k_neighbors_regressor")
62+
63+
# Test 4: Test JSON output
64+
print("\n4. Testing JSON output...")
65+
os.system("python generate_parameter_coverage_docs.py -f k_neighbors_regressor --json")
66+
67+
# Test 5: Test full documentation generation
68+
print("\n5. Testing full documentation generation...")
69+
os.system("python generate_parameter_coverage_docs.py")
70+
71+
print("\n✅ Workflow test completed!")
72+
print("\nGenerated files:")
73+
print("- ML_PARAMETER_COVERAGE.md")
74+
print("- docs/ML_PARAMETER_COVERAGE.md")
75+
print("- docs/ml_parameter_coverage.json")
76+
77+
print(f"\n📊 View the generated documentation: docs/ML_PARAMETER_COVERAGE.md")
78+
79+
# Show current database status
80+
print("\n📈 Current database status:")
81+
os.system("python collect_ml_search_data.py --list")
82+
83+
84+
if __name__ == "__main__":
85+
test_workflow()

0 commit comments

Comments
 (0)