textilindo-ai-assistant / setup_hf_space.py
harismlnaslm's picture
Initial commit: Textilindo AI Assistant for HF Spaces
298d6c1
#!/usr/bin/env python3
"""
Setup script for Hugging Face Spaces deployment
"""
import os
import sys
import subprocess
from pathlib import Path
def check_requirements():
"""Check if all requirements are met"""
print("πŸ” Checking requirements...")
# Check git
try:
subprocess.run(["git", "--version"], capture_output=True, check=True)
print("βœ… Git available")
except (subprocess.CalledProcessError, FileNotFoundError):
print("❌ Git not found. Please install git.")
return False
# Check if we're in the right directory
if not Path("scripts").exists():
print("❌ Scripts directory not found. Please run from project root.")
return False
print("βœ… All requirements met")
return True
def create_space_repository():
"""Guide user to create HF Space repository"""
print("\n🌐 Creating Hugging Face Space Repository")
print("=" * 50)
print("1. Go to https://huggingface.co/spaces")
print("2. Click 'Create new Space'")
print("3. Fill in the details:")
print(" - Name: textilindo-ai-assistant")
print(" - SDK: Docker")
print(" - Hardware: GPU Basic")
print(" - Visibility: Public or Private")
print("4. Click 'Create Space'")
print("5. Copy the repository URL (e.g., https://huggingface.co/spaces/your-username/textilindo-ai-assistant)")
return input("\nπŸ“‹ Enter your Hugging Face Space URL: ").strip()
def setup_git_remote(space_url):
"""Setup git remote for the space"""
print(f"\nπŸ”— Setting up git remote...")
try:
# Remove existing remote if any
subprocess.run(["git", "remote", "remove", "origin"], capture_output=True)
# Add new remote
subprocess.run(["git", "remote", "add", "origin", space_url], check=True)
print(f"βœ… Remote added: {space_url}")
return True
except subprocess.CalledProcessError as e:
print(f"❌ Failed to add remote: {e}")
return False
def main():
"""Main setup function"""
print("πŸš€ Textilindo AI Assistant - Hugging Face Spaces Setup")
print("=" * 60)
# Check requirements
if not check_requirements():
sys.exit(1)
# Guide user to create space
space_url = create_space_repository()
if not space_url:
print("❌ No space URL provided. Exiting.")
sys.exit(1)
# Setup git remote
if not setup_git_remote(space_url):
sys.exit(1)
print("\nβœ… Setup complete!")
print("\nπŸ“‹ Next steps:")
print("1. Run: python push_to_hf_space.py")
print("2. Check your Hugging Face Space")
print("3. Monitor the build logs")
print("4. Test the application when ready")
if __name__ == "__main__":
main()