File size: 6,544 Bytes
d6d843f |
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 |
#!/bin/bash
# Deployment Verification Script
# Run this script to verify the deployment is ready
set -e
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo "β π DEPLOYMENT VERIFICATION SCRIPT β"
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo ""
ERRORS=0
# Check 1: Required files exist
echo "π Check 1: Required files..."
for file in requirements.txt Dockerfile api_server_extended.py provider_fetch_helper.py database.py; do
if [ -f "$file" ]; then
echo " β
$file exists"
else
echo " β $file missing"
((ERRORS++))
fi
done
echo ""
# Check 2: Dockerfile configuration
echo "π³ Check 2: Dockerfile configuration..."
if grep -q "USE_MOCK_DATA=false" Dockerfile; then
echo " β
USE_MOCK_DATA environment variable set"
else
echo " β USE_MOCK_DATA not found in Dockerfile"
((ERRORS++))
fi
if grep -q "mkdir -p logs data exports backups" Dockerfile; then
echo " β
Directory creation configured"
else
echo " β Directory creation missing"
((ERRORS++))
fi
if grep -q "uvicorn api_server_extended:app" Dockerfile; then
echo " β
Uvicorn startup command configured"
else
echo " β Uvicorn startup command missing"
((ERRORS++))
fi
echo ""
# Check 3: Requirements.txt dependencies
echo "π¦ Check 3: Required dependencies..."
for dep in fastapi uvicorn pydantic sqlalchemy aiohttp; do
if grep -q "$dep" requirements.txt; then
echo " β
$dep found in requirements.txt"
else
echo " β $dep missing from requirements.txt"
((ERRORS++))
fi
done
echo ""
# Check 4: USE_MOCK_DATA implementation
echo "π§ Check 4: USE_MOCK_DATA flag implementation..."
if grep -q 'USE_MOCK_DATA = os.getenv("USE_MOCK_DATA"' api_server_extended.py; then
echo " β
USE_MOCK_DATA flag implemented"
else
echo " β USE_MOCK_DATA flag not found"
((ERRORS++))
fi
echo ""
# Check 5: Real data collectors imported
echo "π Check 5: Real data collector imports..."
if grep -q "from collectors.sentiment import get_fear_greed_index" api_server_extended.py; then
echo " β
Sentiment collector imported"
else
echo " β Sentiment collector import missing"
((ERRORS++))
fi
if grep -q "from collectors.market_data import get_coingecko_simple_price" api_server_extended.py; then
echo " β
Market data collector imported"
else
echo " β Market data collector import missing"
((ERRORS++))
fi
if grep -q "from database import get_database" api_server_extended.py; then
echo " β
Database import found"
else
echo " β Database import missing"
((ERRORS++))
fi
echo ""
# Check 6: Mock data removed from endpoints
echo "π« Check 6: Mock data handling..."
MOCK_COUNT=$(grep -c "if USE_MOCK_DATA:" api_server_extended.py || echo "0")
if [ "$MOCK_COUNT" -ge 5 ]; then
echo " β
USE_MOCK_DATA checks found in $MOCK_COUNT locations"
else
echo " β οΈ USE_MOCK_DATA checks found in only $MOCK_COUNT locations (expected 5+)"
((ERRORS++))
fi
echo ""
# Check 7: Database integration
echo "πΎ Check 7: Database integration..."
if grep -q "db.save_price" api_server_extended.py; then
echo " β
Database save_price integration found"
else
echo " β Database save_price integration missing"
((ERRORS++))
fi
if grep -q "db.get_price_history" api_server_extended.py; then
echo " β
Database get_price_history integration found"
else
echo " β Database get_price_history integration missing"
((ERRORS++))
fi
echo ""
# Check 8: Error handling for unimplemented endpoints
echo "β οΈ Check 8: Proper error codes for unimplemented endpoints..."
if grep -q "status_code=503" api_server_extended.py; then
echo " β
HTTP 503 error handling found"
else
echo " β HTTP 503 error handling missing"
((ERRORS++))
fi
if grep -q "status_code=501" api_server_extended.py; then
echo " β
HTTP 501 error handling found"
else
echo " β HTTP 501 error handling missing"
((ERRORS++))
fi
echo ""
# Check 9: Python syntax
echo "π Check 9: Python syntax validation..."
if python3 -m py_compile api_server_extended.py 2>/dev/null; then
echo " β
api_server_extended.py syntax valid"
else
echo " β api_server_extended.py syntax errors"
((ERRORS++))
fi
if python3 -m py_compile provider_fetch_helper.py 2>/dev/null; then
echo " β
provider_fetch_helper.py syntax valid"
else
echo " β provider_fetch_helper.py syntax errors"
((ERRORS++))
fi
echo ""
# Check 10: Documentation
echo "π Check 10: Documentation..."
if [ -f "DEPLOYMENT_INSTRUCTIONS.md" ]; then
echo " β
DEPLOYMENT_INSTRUCTIONS.md exists"
else
echo " β οΈ DEPLOYMENT_INSTRUCTIONS.md missing (recommended)"
fi
if [ -f "AUDIT_COMPLETION_REPORT.md" ]; then
echo " β
AUDIT_COMPLETION_REPORT.md exists"
else
echo " β οΈ AUDIT_COMPLETION_REPORT.md missing (recommended)"
fi
echo ""
# Final verdict
echo "βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
if [ $ERRORS -eq 0 ]; then
echo "β β
ALL CHECKS PASSED β"
echo "β STATUS: READY FOR HUGGINGFACE DEPLOYMENT β
β"
echo "βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo ""
echo "π Next steps:"
echo " 1. docker build -t crypto-monitor ."
echo " 2. docker run -p 7860:7860 crypto-monitor"
echo " 3. Test: curl http://localhost:7860/health"
echo " 4. Deploy to HuggingFace Spaces"
echo ""
exit 0
else
echo "β β FOUND $ERRORS ERROR(S) β"
echo "β STATUS: NOT READY FOR DEPLOYMENT β β"
echo "βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo ""
echo "β οΈ Please fix the errors above before deploying."
echo ""
exit 1
fi
|