superKartapi / deploy_to_hf.py
itsjarvis's picture
Upload deploy_to_hf.py with huggingface_hub
abbb0b9 verified
"""
Hugging Face Space Deployment Helper
====================================
"""
import os
import subprocess
import sys
def deploy_to_huggingface():
"""Deploy SuperKart API to Hugging Face Spaces"""
print("[DEPLOY] SuperKart Sales Forecasting API")
print("=" * 50)
# Check if backend files exist
backend_dir = "backend_files"
if not os.path.exists(backend_dir):
print(f"Error: {backend_dir} directory not found!")
print("Please ensure you're running from the project root directory.")
return False
# List required files
required_files = [
"app.py",
"requirements.txt",
"Dockerfile",
"README.md",
"superkart_sales_forecasting_model.joblib"
]
missing_files = []
for file in required_files:
file_path = os.path.join(backend_dir, file)
if not os.path.exists(file_path):
missing_files.append(file)
if missing_files:
print(f"Error: Missing required files: {missing_files}")
return False
print("βœ… All required files found")
# Instructions for manual deployment
print(f"""
πŸ“ MANUAL DEPLOYMENT STEPS:
1. Create Hugging Face Space:
β€’ Go to: https://huggingface.co/new-space
β€’ Name: superkart-sales-api
β€’ SDK: Docker
β€’ Hardware: CPU Basic
2. Clone your space:
git clone https://huggingface.co/spaces/yourusername/superkart-sales-api
cd superkart-sales-api
3. Copy files:
Copy all files from {backend_dir}/ to your space directory
4. Deploy:
git add .
git commit -m "Initial deployment"
git push origin main
πŸš€ Your API will be live at:
https://yourusername-superkart-sales-api.hf.space
""")
return True
if __name__ == "__main__":
deploy_to_huggingface()