- Archive: 85 agent .txt files → docs/archive/agents/legacy_txt/ - Scripts: Move 110 shell scripts → scripts/ (keep deploy.sh in root) - Models: Move 18 .safetensors → ml/models/checkpoints/training_artifacts/ - Delete: 34 directories (~33GB freed) - target/, coverage_*, test artifacts - Build: Clean 14 build artifacts (.rlib, .o, .pid, binaries) - Tests: Move 14 .rs files → tests/standalone/ - SQL: Move 5 files → sql/ (keep init-db*.sql for Docker) - Wave 153: Archive to docs/archive/historical/wave153/ - Docs: Archive 9 markdown files to wave_d/reports/ and historical/ Total impact: ~34GB freed (both waves), root directory cleaned from 583 to ~40 essential files Directory count reduced from 65 to 31 (52% reduction) All historical data preserved in organized archive structure
97 lines
2.8 KiB
Bash
Executable File
97 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Apply systematic fixes to ML test modules
|
|
# This script adds common test imports to test modules
|
|
|
|
set -e
|
|
|
|
echo "=== Applying ML Test Compilation Fixes ==="
|
|
echo "This script will add common imports to test modules"
|
|
echo ""
|
|
|
|
# Colors for output
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Counter
|
|
fixes_applied=0
|
|
|
|
# Function to add imports to a test module
|
|
fix_test_module() {
|
|
local file=$1
|
|
local needs_device=false
|
|
local needs_file=false
|
|
local needs_tempdir=false
|
|
|
|
# Check what imports are needed
|
|
if grep -q "Device" "$file" && ! grep -q "use candle_core::Device" "$file"; then
|
|
needs_device=true
|
|
fi
|
|
|
|
if grep -q "File\|Write\|Read" "$file" && ! grep -q "use std::fs::File" "$file"; then
|
|
needs_file=true
|
|
fi
|
|
|
|
if grep -q "tempdir" "$file" && ! grep -q "use tempfile::tempdir" "$file"; then
|
|
needs_tempdir=true
|
|
fi
|
|
|
|
# If any imports needed, apply fix
|
|
if [ "$needs_device" = true ] || [ "$needs_file" = true ] || [ "$needs_tempdir" = true ]; then
|
|
echo -e "${YELLOW}Fixing: $file${NC}"
|
|
|
|
# Find the test module line
|
|
test_mod_line=$(grep -n "^#\[cfg(test)\]" "$file" | head -1 | cut -d: -f1)
|
|
|
|
if [ ! -z "$test_mod_line" ]; then
|
|
# Calculate line after "mod tests {"
|
|
mod_tests_line=$((test_mod_line + 1))
|
|
|
|
# Build import string
|
|
imports=" use super::*;"
|
|
|
|
if [ "$needs_device" = true ]; then
|
|
imports="$imports\n use candle_core::{Device, DType};"
|
|
fi
|
|
|
|
if [ "$needs_file" = true ]; then
|
|
imports="$imports\n use std::fs::File;\n use std::io::Write;"
|
|
fi
|
|
|
|
if [ "$needs_tempdir" = true ]; then
|
|
imports="$imports\n use tempfile::tempdir;"
|
|
fi
|
|
|
|
# Apply fix (insert after mod tests { line)
|
|
awk -v modline="$mod_tests_line" -v imports="$imports" '
|
|
NR == modline && /^mod tests \{/ {
|
|
print $0
|
|
print imports
|
|
next
|
|
}
|
|
{print}
|
|
' "$file" > "$file.tmp" && mv "$file.tmp" "$file"
|
|
|
|
fixes_applied=$((fixes_applied + 1))
|
|
echo -e "${GREEN} ✓ Fixed${NC}"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# Find all Rust files with test modules
|
|
echo "Scanning for test modules..."
|
|
test_files=$(find ml/src -name "*.rs" -type f -exec grep -l "#\[cfg(test)\]" {} \;)
|
|
|
|
for file in $test_files; do
|
|
fix_test_module "$file"
|
|
done
|
|
|
|
echo ""
|
|
echo -e "${GREEN}=== Summary ===${NC}"
|
|
echo "Files processed: $(echo "$test_files" | wc -l)"
|
|
echo "Fixes applied: $fixes_applied"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo "1. Run: cargo check -p ml --lib"
|
|
echo "2. Check for remaining errors"
|
|
echo "3. Apply additional fixes as needed" |