-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_all.py
More file actions
168 lines (138 loc) · 5.87 KB
/
run_all.py
File metadata and controls
168 lines (138 loc) · 5.87 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
"""
Hidden Alpha - Run All Script
Generate all dashboards and reports
"""
import os
import sys
import webbrowser
from datetime import datetime
def print_header(title):
"""Print formatted header"""
print("\n" + "=" * 80)
print(f" {title}")
print("=" * 80 + "\n")
def run_script(script_name, description):
"""Run a Python script and handle errors"""
print(f"🔄 {description}...")
try:
# Import and run the script
if script_name == "generate_sources_page":
from generate_sources_page import generate_sources_page
html = generate_sources_page()
output_file = "reports/data_sources.html"
with open(output_file, 'w') as f:
f.write(html)
print(f"✓ {description} complete")
return True
elif script_name == "hidden_alpha":
from hidden_alpha import generate_hidden_alpha_dashboard
html = generate_hidden_alpha_dashboard()
output_file = "reports/hidden_alpha.html"
with open(output_file, 'w') as f:
f.write(html)
print(f"✓ {description} complete")
return True
elif script_name == "hidden_alpha_grouped":
from hidden_alpha_grouped import generate_grouped_dashboard
html = generate_grouped_dashboard()
output_file = "reports/hidden_alpha_grouped.html"
with open(output_file, 'w') as f:
f.write(html)
print(f"✓ {description} complete")
return True
except ImportError as e:
print(f"❌ Error: Could not import {script_name}")
print(f" {str(e)}")
return False
except Exception as e:
print(f"❌ Error running {script_name}:")
print(f" {str(e)}")
return False
def main():
"""Main execution function"""
print("""
╔══════════════════════════════════════════════════════════════════════════════╗
║ HIDDEN ALPHA ║
║ Generate All Dashboards ║
╚══════════════════════════════════════════════════════════════════════════════╝
""")
# Check dependencies
print_header("Checking Dependencies")
print("🔍 Checking Python packages...")
try:
import requests
import bs4
print("✓ All required packages installed")
except ImportError as e:
print("❌ Missing required packages!")
print(f" Error: {str(e)}")
print("\n💡 Install dependencies with: pip install -r requirements.txt")
sys.exit(1)
# Create directories
print("\n📁 Creating directories...")
os.makedirs("reports", exist_ok=True)
os.makedirs("data", exist_ok=True)
print("✓ Directories ready")
# Generate all dashboards
print_header("Generating Dashboards")
results = []
# 1. Data Sources Page
results.append(run_script("generate_sources_page", "Generating Data Sources page"))
# 2. Individual View
results.append(run_script("hidden_alpha", "Generating Individual View dashboard"))
# 3. Grouped View
results.append(run_script("hidden_alpha_grouped", "Generating Grouped by AMC dashboard"))
# Summary
print_header("Summary")
successful = sum(results)
total = len(results)
if successful == total:
print(f"✅ All {total} dashboards generated successfully!\n")
print("📊 Generated Files:")
print(" • reports/data_sources.html (Data verification page)")
print(" • reports/hidden_alpha.html (Individual view)")
print(" • reports/hidden_alpha_grouped.html (Grouped by AMC)")
print("\n🌐 Opening dashboards in browser...")
# Open main dashboard
dashboard_path = os.path.abspath("reports/hidden_alpha.html")
try:
webbrowser.open(f'file://{dashboard_path}')
print("✓ Dashboard opened in browser")
except:
print(f"⚠️ Could not auto-open browser")
print(f" Please manually open: {dashboard_path}")
print(f"\n📍 All files saved to: {os.path.abspath('reports/')}")
print("\n" + "=" * 80)
print(" QUICK ACCESS")
print("=" * 80)
print("\n🔗 View Dashboards:")
print(" • Individual View: reports/hidden_alpha.html")
print(" • Grouped by AMC: reports/hidden_alpha_grouped.html")
print(" • Data Sources: reports/data_sources.html")
print("\n📖 Documentation:")
print(" • README.md - Quick start")
print(" • HIDDEN_ALPHA_README.md - Complete guide")
print(" • SOURCE_ATTRIBUTION_SUMMARY.md - Source info")
print(" • GROUPED_VIEW_SUMMARY.md - Grouped view guide")
print("\n✨ Success! All dashboards are ready.\n")
else:
print(f"⚠️ {successful}/{total} dashboards generated successfully")
print(f" {total - successful} dashboard(s) failed")
print("\n💡 Check error messages above for details")
sys.exit(1)
# Footer
print("=" * 80)
print(f" Generated on {datetime.now().strftime('%B %d, %Y at %I:%M %p')}")
print("=" * 80)
print()
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\n\n⚠️ Generation cancelled by user")
sys.exit(1)
except Exception as e:
print(f"\n❌ Unexpected error: {str(e)}")
import traceback
traceback.print_exc()
sys.exit(1)