-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·388 lines (322 loc) · 11.6 KB
/
run.sh
File metadata and controls
executable file
·388 lines (322 loc) · 11.6 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
#!/bin/bash
# OpenTIR - Comprehensive Analysis Run Script
# This script orchestrates the complete Palantir OSS ecosystem analysis
set -e # Exit on any error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${GREEN}✅ $1${NC}"
}
print_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
print_error() {
echo -e "${RED}❌ $1${NC}"
}
print_info() {
echo -e "${BLUE}ℹ️ $1${NC}"
}
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Change to the project directory
cd "$SCRIPT_DIR"
print_info "Starting OpenTIR Comprehensive Analysis Framework"
echo "=================================================="
# Parse command line arguments
RUN_ADVANCED_STATS=false
FORCE_REANALYSIS=false
SKIP_DEPS_CHECK=false
while [[ $# -gt 0 ]]; do
case $1 in
--advanced-stats|--stats)
RUN_ADVANCED_STATS=true
shift
;;
--force-reanalysis|--force)
FORCE_REANALYSIS=true
shift
;;
--skip-deps)
SKIP_DEPS_CHECK=true
shift
;;
--help|-h)
echo "OpenTIR Usage:"
echo " ./run.sh [OPTIONS]"
echo ""
echo "Options:"
echo " --advanced-stats Run comprehensive statistical analysis with ANOVA, PCA, clustering"
echo " --force-reanalysis Force fresh analysis (ignore cached results)"
echo " --skip-deps Skip dependency installation check"
echo " --help Show this help message"
echo ""
echo "Examples:"
echo " ./run.sh # Basic analysis"
echo " ./run.sh --advanced-stats # Full statistical analysis"
echo " ./run.sh --force --advanced-stats # Fresh comprehensive analysis"
exit 0
;;
*)
print_warning "Unknown option: $1"
print_info "Use --help for usage information"
exit 1
;;
esac
done
# Check if virtual environment exists
if [ ! -d "venv" ]; then
print_info "Virtual environment not found. Creating one..."
python3 -m venv venv
print_status "Virtual environment created"
fi
# Activate virtual environment
print_info "Activating virtual environment..."
source venv/bin/activate
# Function to check if a Python package is installed
check_package() {
python -c "import $1" 2>/dev/null
return $?
}
# Install or upgrade dependencies if needed
if [ "$SKIP_DEPS_CHECK" = false ]; then
print_info "Checking dependencies..."
# Check core dependencies
NEED_INSTALL=false
if ! check_package "aiohttp"; then
NEED_INSTALL=true
fi
if ! check_package "pandas"; then
NEED_INSTALL=true
fi
if ! check_package "numpy"; then
NEED_INSTALL=true
fi
if ! check_package "matplotlib"; then
NEED_INSTALL=true
fi
if ! check_package "seaborn"; then
NEED_INSTALL=true
fi
if ! check_package "scipy"; then
NEED_INSTALL=true
fi
if ! check_package "sklearn"; then
NEED_INSTALL=true
fi
if ! check_package "plotly"; then
NEED_INSTALL=true
fi
if [ "$NEED_INSTALL" = true ]; then
print_info "Installing/updating dependencies..."
pip install --upgrade pip
pip install -r requirements.txt
print_status "Dependencies installed/updated"
else
print_status "All dependencies are available"
fi
else
print_warning "Skipping dependency check (--skip-deps flag used)"
fi
# Verify repository structure
print_info "Verifying project structure..."
if [ ! -d "src" ]; then
print_error "src/ directory not found!"
exit 1
fi
if [ ! -d "repos" ]; then
print_warning "repos/ directory not found. Analysis will attempt to create it."
fi
if [ ! -f "src/main.py" ]; then
print_error "src/main.py not found!"
exit 1
fi
print_status "Project structure verified"
# Display analysis configuration
echo ""
print_info "Analysis Configuration:"
echo " - Force Reanalysis: $FORCE_REANALYSIS"
echo " - Advanced Statistics: $RUN_ADVANCED_STATS"
echo " - Working Directory: $SCRIPT_DIR"
echo ""
# Function to run analysis with error handling
run_analysis() {
local analysis_type=$1
local script_path=$2
print_info "Starting $analysis_type..."
if [ "$FORCE_REANALYSIS" = true ]; then
print_info "Force reanalysis enabled - clearing cache..."
rm -f multi_repo_analysis/cross_repo_analysis.json
rm -f multi_repo_analysis/cross_repo_patterns.json
fi
if python "$script_path" "$@"; then
print_status "$analysis_type completed successfully"
return 0
else
print_error "$analysis_type failed with exit code $?"
return 1
fi
}
# Run main analysis
echo "🚀 Starting Primary Analysis..."
echo "================================"
if run_analysis "Primary Repository Analysis" "main.py"; then
print_status "Primary analysis completed"
# Check if outputs were generated
if [ -d "multi_repo_analysis" ]; then
echo ""
print_info "Generated outputs:"
find multi_repo_analysis -name "*.md" -o -name "*.png" -o -name "*.json" -o -name "*.csv" | head -10 | while read file; do
echo " 📄 $file"
done
file_count=$(find multi_repo_analysis -type f | wc -l)
print_status "Total output files: $file_count"
fi
else
print_error "Primary analysis failed!"
exit 1
fi
# Run advanced statistical analysis if requested
if [ "$RUN_ADVANCED_STATS" = true ]; then
echo ""
echo "📊 Starting Advanced Statistical Analysis..."
echo "==========================================="
if [ -f "examples/advanced_statistical_analysis.py" ]; then
if run_analysis "Advanced Statistical Analysis" "examples/advanced_statistical_analysis.py"; then
print_status "Advanced statistical analysis completed"
# Check for additional statistical outputs
if [ -d "advanced_analysis_results" ]; then
echo ""
print_info "Statistical analysis outputs:"
find advanced_analysis_results -name "*.png" -o -name "*.html" -o -name "*.json" | head -10 | while read file; do
echo " 📊 $file"
done
stats_file_count=$(find advanced_analysis_results -type f | wc -l)
print_status "Statistical output files: $stats_file_count"
fi
else
print_warning "Advanced statistical analysis failed, but continuing..."
fi
else
print_warning "Advanced statistical analysis script not found"
fi
fi
# Summary and next steps
echo ""
echo "🎉 Analysis Complete!"
echo "===================="
# Generate clickable file summary
absolute_path=$(pwd)
print_info "📄 Generated Analysis Files (ctrl+click to open):"
echo ""
# Executive and Technical Reports
if [ -f "multi_repo_analysis/reports/executive_summary.md" ]; then
echo " 📊 Executive Summary:"
echo " file://$absolute_path/multi_repo_analysis/reports/executive_summary.md"
fi
if [ -f "multi_repo_analysis/reports/technical_report.md" ]; then
echo " 🔬 Technical Report:"
echo " file://$absolute_path/multi_repo_analysis/reports/technical_report.md"
fi
if [ -f "multi_repo_analysis/reports/language_analysis.md" ]; then
echo " 🔤 Language Analysis:"
echo " file://$absolute_path/multi_repo_analysis/reports/language_analysis.md"
fi
if [ -f "multi_repo_analysis/reports/repository_rankings.md" ]; then
echo " 🏆 Repository Rankings:"
echo " file://$absolute_path/multi_repo_analysis/reports/repository_rankings.md"
fi
echo ""
print_info "📈 Visualizations (ctrl+click to open):"
# Visualizations
if [ -d "multi_repo_analysis/visualizations" ]; then
for viz_file in multi_repo_analysis/visualizations/*.png; do
if [ -f "$viz_file" ]; then
viz_name=$(basename "$viz_file" .png)
echo " 🖼️ $(echo $viz_name | sed 's/_/ /g' | sed 's/\b\w/\U&/g'):"
echo " file://$absolute_path/$viz_file"
fi
done
fi
echo ""
print_info "📊 Data Files (ctrl+click to open):"
# CSV exports
if [ -d "multi_repo_analysis/reports/csv_exports" ]; then
for csv_file in multi_repo_analysis/reports/csv_exports/*.csv; do
if [ -f "$csv_file" ]; then
csv_name=$(basename "$csv_file" .csv)
echo " 📋 $(echo $csv_name | sed 's/_/ /g' | sed 's/\b\w/\U&/g'):"
echo " file://$absolute_path/$csv_file"
fi
done
fi
# JSON analysis files
if [ -f "multi_repo_analysis/cross_repo_analysis.json" ]; then
echo " 🔗 Cross-Repository Analysis:"
echo " file://$absolute_path/multi_repo_analysis/cross_repo_analysis.json"
fi
if [ -f "multi_repo_analysis/cross_repo_patterns.json" ]; then
echo " 🎯 Cross-Repository Patterns:"
echo " file://$absolute_path/multi_repo_analysis/cross_repo_patterns.json"
fi
# Advanced statistical analysis outputs
if [ "$RUN_ADVANCED_STATS" = true ] && [ -d "advanced_analysis_results" ]; then
echo ""
print_info "📊 Advanced Statistical Analysis (ctrl+click to open):"
for stats_file in advanced_analysis_results/*.png advanced_analysis_results/*.html; do
if [ -f "$stats_file" ]; then
stats_name=$(basename "$stats_file")
extension=$(echo "$stats_name" | sed 's/.*\.//')
name_without_ext=$(echo "$stats_name" | sed 's/\.[^.]*$//')
echo " 📈 $(echo $name_without_ext | sed 's/_/ /g' | sed 's/\b\w/\U&/g'):"
echo " file://$absolute_path/$stats_file"
fi
done
fi
echo ""
print_info "📁 Directory Navigation (ctrl+click to open):"
echo " 📂 All Analysis Results:"
echo " file://$absolute_path/multi_repo_analysis/"
echo " 📊 Visualizations Directory:"
echo " file://$absolute_path/multi_repo_analysis/visualizations/"
echo " 📄 Reports Directory:"
echo " file://$absolute_path/multi_repo_analysis/reports/"
echo " 🔢 CSV Data Exports:"
echo " file://$absolute_path/multi_repo_analysis/reports/csv_exports/"
echo " 📋 Individual Analyses:"
echo " file://$absolute_path/multi_repo_analysis/individual_analyses/"
# Count total outputs
total_files=0
if [ -d "multi_repo_analysis" ]; then
primary_files=$(find multi_repo_analysis -type f | wc -l)
total_files=$((total_files + primary_files))
fi
if [ -d "advanced_analysis_results" ] && [ "$RUN_ADVANCED_STATS" = true ]; then
stats_files=$(find advanced_analysis_results -type f | wc -l)
total_files=$((total_files + stats_files))
fi
echo ""
print_info "Summary:"
echo " 📁 Total output files generated: $total_files"
echo " 🔍 Primary analysis: ✅"
if [ "$RUN_ADVANCED_STATS" = true ]; then
echo " 📊 Advanced statistics: ✅"
else
echo " 📊 Advanced statistics: ⏭️ (use --advanced-stats to enable)"
fi
echo ""
print_info "Quick Commands:"
echo " • Run with advanced stats: ./run.sh --advanced-stats"
echo " • Force reanalysis: ./run.sh --force-reanalysis"
echo " • Both options: ./run.sh --advanced-stats --force-reanalysis"
echo ""
print_status "OpenTIR analysis framework completed successfully!"
# Optional: Open results in browser (commented out by default)
# if command -v open >/dev/null 2>&1; then
# print_info "Opening results in browser..."
# open multi_repo_analysis/reports/executive_summary.md
# fi