DEMO-nebula-emergent / nebula_deploy_script.sh
Agnuxo's picture
Upload 6 files
4a0fa9c verified
#!/bin/bash
# NEBULA EMERGENT - Deployment Script for Hugging Face Spaces
# Author: Francisco Angulo de Lafuente
# This script helps deploy the NEBULA EMERGENT system to Hugging Face Spaces
echo "🌌 NEBULA EMERGENT - Hugging Face Space Deployment Script"
echo "========================================================="
# Configuration
SPACE_NAME="nebula-emergent"
HF_USERNAME="Agnuxo"
SPACE_URL="https://huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${GREEN}βœ… $1${NC}"
}
print_error() {
echo -e "${RED}❌ $1${NC}"
}
print_info() {
echo -e "${BLUE}ℹ️ $1${NC}"
}
print_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
# Check if git is installed
if ! command -v git &> /dev/null; then
print_error "Git is not installed. Please install git first."
exit 1
fi
# Check if huggingface-cli is installed
if ! command -v huggingface-cli &> /dev/null; then
print_warning "huggingface-cli is not installed."
echo "Installing huggingface-hub..."
pip install huggingface-hub
fi
# Step 1: Login to Hugging Face
print_info "Step 1: Logging in to Hugging Face..."
echo "Please make sure you're logged in to Hugging Face."
echo "If not logged in, run: huggingface-cli login"
read -p "Press Enter to continue..."
# Step 2: Clone or create the Space repository
print_info "Step 2: Setting up Space repository..."
if [ -d "$SPACE_NAME" ]; then
print_warning "Directory $SPACE_NAME already exists."
read -p "Do you want to remove it and start fresh? (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -rf "$SPACE_NAME"
print_status "Removed existing directory."
else
cd "$SPACE_NAME"
git pull
print_status "Updated existing repository."
fi
fi
if [ ! -d "$SPACE_NAME" ]; then
print_info "Cloning Space repository..."
git clone "https://huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME" 2>/dev/null
if [ $? -ne 0 ]; then
print_warning "Space doesn't exist. Creating new Space..."
mkdir "$SPACE_NAME"
cd "$SPACE_NAME"
git init
git remote add origin "https://huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME"
print_status "Initialized new repository."
else
cd "$SPACE_NAME"
print_status "Cloned existing Space."
fi
else
cd "$SPACE_NAME"
fi
# Step 3: Copy files
print_info "Step 3: Copying project files..."
# Create the files if they don't exist in the parent directory
if [ ! -f "../app.py" ]; then
print_error "app.py not found in parent directory!"
print_info "Please ensure app.py is in the same directory as this script."
exit 1
fi
cp ../app.py ./app.py
cp ../requirements.txt ./requirements.txt
cp ../README.md ./README.md
print_status "Files copied successfully."
# Step 4: Create .gitignore
print_info "Step 4: Creating .gitignore..."
cat > .gitignore << 'EOF'
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
.env
.venv
env/
venv/
ENV/
.DS_Store
*.log
flagged/
gradio_cached_examples/
EOF
print_status ".gitignore created."
# Step 5: Verify file structure
print_info "Step 5: Verifying file structure..."
echo "Current files in Space directory:"
ls -la
# Step 6: Add and commit files
print_info "Step 6: Committing files to git..."
git add .
git commit -m "πŸš€ Deploy NEBULA EMERGENT - Physical Neural Computing System
- Complete implementation with 1M+ neuron simulation
- Gravitational dynamics, photon propagation, quantum effects
- Interactive Gradio interface with 3D visualization
- Problem solving capabilities (TSP, pattern recognition)
- Real-time metrics and data export
Author: Francisco Angulo de Lafuente"
print_status "Files committed."
# Step 7: Push to Hugging Face
print_info "Step 7: Pushing to Hugging Face Spaces..."
print_warning "This may take a few minutes..."
git push origin main 2>/dev/null || git push origin master 2>/dev/null
if [ $? -eq 0 ]; then
print_status "Successfully pushed to Hugging Face!"
echo
print_info "πŸŽ‰ Your Space is being built and will be available at:"
echo -e "${GREEN}$SPACE_URL${NC}"
echo
print_info "It may take a few minutes for the Space to build and start."
print_info "You can check the build logs on the Hugging Face website."
else
print_error "Failed to push. You may need to:"
echo "1. Run: huggingface-cli login"
echo "2. Create the Space manually at: https://huggingface.co/new-space"
echo "3. Then run this script again"
fi
# Step 8: Create local test script
print_info "Step 8: Creating local test script..."
cat > ../test_local.py << 'EOF'
#!/usr/bin/env python3
"""
Local test script for NEBULA EMERGENT
Run this to test the system locally before deploying
"""
import subprocess
import sys
print("πŸ§ͺ Testing NEBULA EMERGENT locally...")
print("=" * 50)
# Check Python version
print(f"Python version: {sys.version}")
# Check required packages
required = ['gradio', 'numpy', 'scipy', 'pandas', 'plotly', 'scikit-learn', 'numba']
missing = []
for package in required:
try:
__import__(package)
print(f"βœ… {package} is installed")
except ImportError:
print(f"❌ {package} is missing")
missing.append(package)
if missing:
print("\n⚠️ Installing missing packages...")
subprocess.run([sys.executable, "-m", "pip", "install"] + missing)
print("\nπŸš€ Starting local server...")
print("Open http://localhost:7860 in your browser")
print("Press Ctrl+C to stop\n")
# Run the app
subprocess.run([sys.executable, "app.py"])
EOF
chmod +x ../test_local.py
print_status "Local test script created: test_local.py"
# Final summary
echo
echo "========================================================="
print_status "🎊 Deployment script completed!"
echo
echo "πŸ“‹ Summary:"
echo " - Space Name: $SPACE_NAME"
echo " - Username: $HF_USERNAME"
echo " - URL: $SPACE_URL"
echo
echo "πŸ“ Next steps:"
echo " 1. Visit your Space URL to see it in action"
echo " 2. Check the logs if the build fails"
echo " 3. Run ./test_local.py to test locally"
echo
echo "🌟 Tips:"
echo " - The first build may take 5-10 minutes"
echo " - If you see errors, check the build logs on HF"
echo " - You can update the Space by running this script again"
echo
print_info "Thank you for using NEBULA EMERGENT!"
echo "========================================================="