Spaces:
Sleeping
Sleeping
Upload deploy_to_hf.py with huggingface_hub
Browse files- deploy_to_hf.py +73 -0
deploy_to_hf.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Hugging Face Space Deployment Helper
|
| 3 |
+
====================================
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import os
|
| 7 |
+
import subprocess
|
| 8 |
+
import sys
|
| 9 |
+
|
| 10 |
+
def deploy_to_huggingface():
|
| 11 |
+
"""Deploy SuperKart API to Hugging Face Spaces"""
|
| 12 |
+
|
| 13 |
+
print("[DEPLOY] SuperKart Sales Forecasting API")
|
| 14 |
+
print("=" * 50)
|
| 15 |
+
|
| 16 |
+
# Check if backend files exist
|
| 17 |
+
backend_dir = "backend_files"
|
| 18 |
+
if not os.path.exists(backend_dir):
|
| 19 |
+
print(f"Error: {backend_dir} directory not found!")
|
| 20 |
+
print("Please ensure you're running from the project root directory.")
|
| 21 |
+
return False
|
| 22 |
+
|
| 23 |
+
# List required files
|
| 24 |
+
required_files = [
|
| 25 |
+
"app.py",
|
| 26 |
+
"requirements.txt",
|
| 27 |
+
"Dockerfile",
|
| 28 |
+
"README.md",
|
| 29 |
+
"superkart_sales_forecasting_model.joblib"
|
| 30 |
+
]
|
| 31 |
+
|
| 32 |
+
missing_files = []
|
| 33 |
+
for file in required_files:
|
| 34 |
+
file_path = os.path.join(backend_dir, file)
|
| 35 |
+
if not os.path.exists(file_path):
|
| 36 |
+
missing_files.append(file)
|
| 37 |
+
|
| 38 |
+
if missing_files:
|
| 39 |
+
print(f"Error: Missing required files: {missing_files}")
|
| 40 |
+
return False
|
| 41 |
+
|
| 42 |
+
print("✅ All required files found")
|
| 43 |
+
|
| 44 |
+
# Instructions for manual deployment
|
| 45 |
+
print(f"""
|
| 46 |
+
📝 MANUAL DEPLOYMENT STEPS:
|
| 47 |
+
|
| 48 |
+
1. Create Hugging Face Space:
|
| 49 |
+
• Go to: https://huggingface.co/new-space
|
| 50 |
+
• Name: superkart-sales-api
|
| 51 |
+
• SDK: Docker
|
| 52 |
+
• Hardware: CPU Basic
|
| 53 |
+
|
| 54 |
+
2. Clone your space:
|
| 55 |
+
git clone https://huggingface.co/spaces/yourusername/superkart-sales-api
|
| 56 |
+
cd superkart-sales-api
|
| 57 |
+
|
| 58 |
+
3. Copy files:
|
| 59 |
+
Copy all files from {backend_dir}/ to your space directory
|
| 60 |
+
|
| 61 |
+
4. Deploy:
|
| 62 |
+
git add .
|
| 63 |
+
git commit -m "Initial deployment"
|
| 64 |
+
git push origin main
|
| 65 |
+
|
| 66 |
+
🚀 Your API will be live at:
|
| 67 |
+
https://yourusername-superkart-sales-api.hf.space
|
| 68 |
+
""")
|
| 69 |
+
|
| 70 |
+
return True
|
| 71 |
+
|
| 72 |
+
if __name__ == "__main__":
|
| 73 |
+
deploy_to_huggingface()
|