-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate_src_migration.sh
More file actions
158 lines (142 loc) · 4.22 KB
/
validate_src_migration.sh
File metadata and controls
158 lines (142 loc) · 4.22 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
#!/bin/bash
# Validation script for src directory migration
# This script verifies that the src submodule has been successfully removed
# and replaced with regular Python source files
echo "=========================================================================="
echo "MedRAG Source Directory Validation"
echo "=========================================================================="
echo ""
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
PASS=0
FAIL=0
# Test 1: Check for .gitmodules file
echo -n "1. Checking for .gitmodules file... "
if [ ! -f .gitmodules ]; then
echo -e "${GREEN}✓ PASS${NC} (No .gitmodules file)"
((PASS++))
else
echo -e "${RED}✗ FAIL${NC} (.gitmodules exists)"
((FAIL++))
fi
# Test 2: Check git submodule status
echo -n "2. Checking git submodule status... "
SUBMODULE_OUTPUT=$(git submodule status 2>&1)
if [ -z "$SUBMODULE_OUTPUT" ]; then
echo -e "${GREEN}✓ PASS${NC} (No submodules configured)"
((PASS++))
else
echo -e "${RED}✗ FAIL${NC} (Submodules found)"
((FAIL++))
fi
# Test 3: Check for mode 160000 entries (submodule references)
echo -n "3. Checking for submodule entries in git index... "
SUBMODULE_ENTRIES=$(git ls-files --stage | grep "^160000" || echo "")
if [ -z "$SUBMODULE_ENTRIES" ]; then
echo -e "${GREEN}✓ PASS${NC} (No submodule entries)"
((PASS++))
else
echo -e "${RED}✗ FAIL${NC} (Submodule entries found)"
((FAIL++))
fi
# Test 4: Check src directory exists
echo -n "4. Checking src directory exists... "
if [ -d "src" ]; then
echo -e "${GREEN}✓ PASS${NC}"
((PASS++))
else
echo -e "${RED}✗ FAIL${NC}"
((FAIL++))
fi
# Test 5: Check for required Python files
echo -n "5. Checking for required Python files... "
REQUIRED_FILES=(
"src/__init__.py"
"src/model_registry.py"
"src/ledger.py"
"src/inference.py"
"src/models.py"
"src/demo_rag_vfl.py"
"src/Aggregator.sol"
)
MISSING_FILES=()
for file in "${REQUIRED_FILES[@]}"; do
if [ ! -f "$file" ]; then
MISSING_FILES+=("$file")
fi
done
if [ ${#MISSING_FILES[@]} -eq 0 ]; then
echo -e "${GREEN}✓ PASS${NC} (All required files present)"
((PASS++))
else
echo -e "${RED}✗ FAIL${NC} (Missing files: ${MISSING_FILES[*]})"
((FAIL++))
fi
# Test 6: Check Python syntax
echo -n "6. Checking Python syntax... "
SYNTAX_OK=true
for pyfile in src/*.py; do
if [ -f "$pyfile" ]; then
if ! python -m py_compile "$pyfile" 2>/dev/null; then
SYNTAX_OK=false
break
fi
fi
done
if $SYNTAX_OK; then
echo -e "${GREEN}✓ PASS${NC}"
((PASS++))
else
echo -e "${RED}✗ FAIL${NC} (Syntax errors found)"
((FAIL++))
fi
# Test 7: Check git tracking
echo -n "7. Checking git tracking of src files... "
TRACKED_FILES=$(git ls-files src/ | wc -l)
if [ "$TRACKED_FILES" -gt 0 ]; then
echo -e "${GREEN}✓ PASS${NC} ($TRACKED_FILES files tracked)"
((PASS++))
else
echo -e "${RED}✗ FAIL${NC} (No files tracked in src/)"
((FAIL++))
fi
# Test 8: Check for documentation
echo -n "8. Checking for documentation... "
if [ -f "src/README.md" ]; then
echo -e "${GREEN}✓ PASS${NC}"
((PASS++))
else
echo -e "${YELLOW}⚠ WARNING${NC} (No README in src/)"
((PASS++)) # Don't fail on this
fi
# Summary
echo ""
echo "=========================================================================="
echo "Validation Summary"
echo "=========================================================================="
echo -e "Tests Passed: ${GREEN}$PASS${NC}"
echo -e "Tests Failed: ${RED}$FAIL${NC}"
echo ""
if [ $FAIL -eq 0 ]; then
echo -e "${GREEN}✓ All validation tests passed!${NC}"
echo ""
echo "The src directory has been successfully migrated from a submodule"
echo "to a regular directory with Python source files."
echo ""
echo "Next steps:"
echo " 1. Review the created files in src/"
echo " 2. Implement any missing functionality"
echo " 3. Run: python -m pytest tests/"
echo " 4. Test the demo: python src/demo_rag_vfl.py --help"
echo ""
exit 0
else
echo -e "${RED}✗ Some validation tests failed!${NC}"
echo ""
echo "Please review the failures above and fix them before proceeding."
echo ""
exit 1
fi