| |
| """ |
| Helper script to upload Devam Jersey Server to Hugging Face Spaces |
| """ |
|
|
| import os |
| import subprocess |
| import sys |
|
|
| def run_command(command, description): |
| """Run a command and handle errors""" |
| print(f"π {description}...") |
| try: |
| result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True) |
| print(f"β
{description} completed successfully") |
| return result.stdout |
| except subprocess.CalledProcessError as e: |
| print(f"β {description} failed:") |
| print(f"Error: {e.stderr}") |
| return None |
|
|
| def check_git_status(): |
| """Check if we're in a git repository and if it's clean""" |
| if not os.path.exists('.git'): |
| print("β Not in a git repository. Please initialize git first:") |
| print(" git init") |
| print(" git add .") |
| print(" git commit -m 'Initial commit'") |
| return False |
| |
| |
| result = subprocess.run("git status --porcelain", shell=True, capture_output=True, text=True) |
| if result.stdout.strip(): |
| print("β οΈ There are uncommitted changes. Please commit them first:") |
| print(" git add .") |
| print(" git commit -m 'Update before HF upload'") |
| return False |
| |
| return True |
|
|
| def main(): |
| print("π Devam Jersey Server - Hugging Face Upload Helper") |
| print("=" * 50) |
| |
| |
| if not check_git_status(): |
| return |
| |
| |
| try: |
| import huggingface_hub |
| print("β
huggingface_hub is installed") |
| except ImportError: |
| print("β huggingface_hub not found. Installing...") |
| run_command("pip install huggingface_hub", "Installing huggingface_hub") |
| |
| print("\nπ Next steps to upload to Hugging Face:") |
| print("1. Go to https://huggingface.co/spaces") |
| print("2. Click 'Create new Space'") |
| print("3. Choose 'Docker' as the SDK") |
| print("4. Set Space name (e.g., 'devam-jersey-server')") |
| print("5. Set visibility (Public or Private)") |
| print("6. Click 'Create Space'") |
| print("\n7. Clone the created space:") |
| print(" git clone https://huggingface.co/spaces/YOUR_USERNAME/devam-jersey-server") |
| print(" cd devam-jersey-server") |
| print("\n8. Copy your project files to the cloned directory") |
| print("9. Push to Hugging Face:") |
| print(" git add .") |
| print(" git commit -m 'Initial upload'") |
| print(" git push") |
| |
| print("\nπ§ Alternative: Use huggingface_hub CLI") |
| print(" huggingface-cli repo create devam-jersey-server --type space --space-sdk docker") |
| print(" cd devam-jersey-server") |
| print(" # Copy files and push as above") |
| |
| print("\nπ Important notes:") |
| print("- Make sure your model files are not too large (>5GB total)") |
| print("- The space will automatically build and deploy your Docker container") |
| print("- Check the 'Settings' tab in your space for environment variables if needed") |
| print("- Monitor the build logs in the 'Logs' tab") |
|
|
| if __name__ == "__main__": |
| main() |
|
|