-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (113 loc) · 4.79 KB
/
Makefile
File metadata and controls
129 lines (113 loc) · 4.79 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
.PHONY: help update postprocess plot clean test install lint format check-csv
# Default target
help:
@echo "Available commands:"
@echo " make update - Complete data update workflow (recommended for annual updates)"
@echo " make install - Install dependencies using Poetry"
@echo " make download-only - Download latest data without processing"
@echo " make postprocess - Post-process and sort data files"
@echo " make fix-riders-history - Fix riders history from all rankings data"
@echo " make plot - Generate plots from existing data"
@echo " make all - Legacy command (use 'update' instead)"
@echo " make clean - Clean temporary files and caches"
@echo " make test - Run tests"
@echo " make lint - Run linting checks"
@echo " make format - Format code"
@echo " make check-csv - Check CSV file integrity"
# Install dependencies
install:
@echo "Installing dependencies with Poetry..."
poetry install
@echo "✅ Dependencies installed successfully"
# Complete data update workflow (download, postprocess, fix, verify)
update:
@echo "🔄 Starting complete data update workflow..."
@echo "📥 Step 1: Downloading latest Tour de France data..."
cd scripts && poetry run python download_data.py
@echo "🔧 Step 2: Post-processing data files..."
cd scripts && poetry run python postprocess_data.py
@echo "🩹 Step 3: Fixing riders history if needed..."
poetry run python scripts/fix_riders_history.py || echo "⚠️ Fix script completed with warnings (may be expected)"
@echo "🛡️ Step 4: Verifying CSV integrity..."
poetry run python .github/scripts/check_csv_integrity.py
@echo "📊 Step 5: Generating plots..."
cd scripts && poetry run python generate_plots.py
@echo "✅ Complete data update workflow finished successfully!"
@echo "📋 Next steps: Review changes and commit/push if everything looks good"
# Quick data download only (no postprocessing or plots)
download-only:
@echo "📥 Downloading latest Tour de France data only..."
cd scripts && poetry run python download_data.py
@echo "✅ Data download completed"
@echo "🔧 Post-processing data files..."
cd scripts && poetry run python postprocess_data.py
@echo "✅ Post-processing completed"
# Post-process data files (sort and organize)
# Post-process data files (sort and organize)
postprocess:
@echo "🔧 Post-processing data files..."
cd scripts && poetry run python postprocess_data.py
@echo "✅ Post-processing completed"
# Fix riders history (extract GC from all rankings if missing)
fix-riders-history:
@echo "🔧 Fixing riders history files..."
poetry run python scripts/fix_riders_history.py
@echo "✅ Riders history fixed"
# Generate plots from existing data
plot:
@echo "📊 Generating plots..."
cd scripts && poetry run python generate_plots.py
@echo "✅ Plots generated successfully"
# Legacy: Run both update and plot (deprecated - use 'update' instead)
all: update
@echo "ℹ️ Note: 'make all' is deprecated. Use 'make update' for the complete workflow."
@echo "✅ All tasks completed"
# Clean temporary files
clean:
@echo "🧹 Cleaning temporary files..."
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete 2>/dev/null || true
find . -type f -name "*.pyo" -delete 2>/dev/null || true
find . -type f -name ".DS_Store" -delete 2>/dev/null || true
@echo "✅ Cleanup completed"
# Run tests
test:
@echo "🧪 Running tests..."
cd tests && poetry run python test_recent_links.py
cd tests && poetry run python test_recent_download.py
cd tests && poetry run python debug_latest_data.py
@echo "✅ Tests completed"
# Run linting
lint:
@echo "🔍 Running linting checks..."
poetry run flake8 src/ scripts/ tests/ --max-line-length=88 --extend-ignore=E203,W503
@echo "✅ Linting completed"
# Format code
format:
@echo "🎨 Formatting code..."
poetry run black src/ scripts/ tests/
poetry run isort src/ scripts/ tests/
@echo "✅ Code formatting completed"
# Check CSV integrity
check-csv:
@echo "🛡️ Checking CSV file integrity..."
poetry run python .github/scripts/check_csv_integrity.py
@echo "✅ CSV integrity check completed"
# Development workflow
dev: install lint test
@echo "✅ Development setup completed"
# CI workflow
ci: install lint test check-csv
@echo "✅ CI pipeline completed"
# Move existing CSV files to new structure (one-time migration)
migrate-data:
@echo "📁 Migrating data to new folder structure..."
@if [ -f "data/TDF_Riders_History.csv" ]; then \
mkdir -p data/men data/women data/plots; \
mv data/TDF_*.csv data/men/ 2>/dev/null || true; \
mv data/TDFF_*.csv data/women/ 2>/dev/null || true; \
mv data/*.png data/plots/ 2>/dev/null || true; \
echo "✅ Data migration completed"; \
else \
echo "ℹ️ No legacy data files found to migrate"; \
fi