HNTAI / entrypoint.sh
sachinchandrankallar's picture
Update .gitignore to include additional files and directories for macOS, Linux, and application-specific configurations. Modify .huggingface.yaml to enhance Docker build settings and hardware requirements. Refactor app.py to remove legacy code and improve error handling. Remove deprecated files related to comprehensive streaming fixes, deployment scripts, and optimized Docker configurations. Update Dockerfile.prod to extend Gunicorn timeout for better performance. Enhance health endpoints and model management with improved logging and error handling. Consolidate routes and simplify architecture for better maintainability.
af75202
Raw
History Blame
1.86 kB
#!/bin/bash
set -e
echo "=============================================================================="
echo "Starting Medical AI Service on Hugging Face Spaces"
echo "=============================================================================="
# Print environment info
echo ""
echo "πŸ“‹ Environment Configuration:"
echo " SPACE_ID: ${SPACE_ID:-'Not set'}"
echo " HF_SPACES: ${HF_SPACES:-'false'}"
echo " CUDA_VISIBLE_DEVICES: ${CUDA_VISIBLE_DEVICES:-'Not set'}"
echo " HF_HOME: ${HF_HOME}"
echo " MODEL_CACHE_DIR: ${MODEL_CACHE_DIR}"
echo ""
# Check if GPU is available
if command -v nvidia-smi &> /dev/null; then
echo "πŸ” Checking GPU availability..."
nvidia-smi --query-gpu=name,memory.total,memory.free --format=csv,noheader || echo "⚠️ nvidia-smi failed"
echo ""
fi
# Verify model cache
echo "πŸ” Verifying model cache..."
if [ -f "/app/verify_cache.py" ]; then
python3 /app/verify_cache.py || echo "⚠️ Cache verification had warnings"
else
echo "⚠️ verify_cache.py not found, skipping verification"
fi
echo ""
# Create runtime directories
echo "πŸ“ Creating runtime directories..."
mkdir -p /tmp/uploads /tmp/matplotlib
chmod -R 777 /tmp/uploads /tmp/matplotlib 2>/dev/null || true
echo ""
# Display cache sizes
echo "πŸ’Ύ Cache directory sizes:"
du -sh ${HF_HOME} 2>/dev/null || echo " HF_HOME not found"
du -sh ${MODEL_CACHE_DIR} 2>/dev/null || echo " MODEL_CACHE_DIR not found"
du -sh ${TORCH_HOME} 2>/dev/null || echo " TORCH_HOME not found"
du -sh ${WHISPER_CACHE} 2>/dev/null || echo " WHISPER_CACHE not found"
echo ""
echo "=============================================================================="
echo "πŸš€ Starting application server..."
echo "=============================================================================="
echo ""
# Execute the main command
exec "$@"