CoolFace
Apppublic

anu151105/agentic-browser

sourceHugging Facemitupdated 1y agoView on Hugging Face
2likes
deploy.py116 linesDownload Raw Back to root
1#!/usr/bin/env python32"""3Deployment script for Hugging Face Spaces4"""5import os6import subprocess7import sys8 9def run_command(command, description):10    """Run a shell command and handle errors."""11    print(f"๐Ÿ”ง {description}...")12    try:13        result = subprocess.run(command, shell=True, capture_output=True, text=True)14        if result.returncode == 0:15            print(f"โœ… {description} completed successfully")16            if result.stdout.strip():17                print(f"   Output: {result.stdout.strip()}")18        else:19            print(f"โŒ {description} failed")20            if result.stderr.strip():21                print(f"   Error: {result.stderr.strip()}")22            return False23    except Exception as e:24        print(f"โŒ {description} failed with exception: {e}")25        return False26    return True27 28def main():29    """Main deployment function."""30    print("๐Ÿš€ Agentic Browser - Hugging Face Spaces Deployment")31    print("=" * 55)32    33    # Check if we're in the right directory34    if not os.path.exists("app.py"):35        print("โŒ Error: app.py not found. Please run this script from the project root.")36        return False37    38    # Check if git is installed39    if not run_command("git --version", "Checking Git installation"):40        print("โŒ Git is not installed. Please install Git first.")41        return False42    43    # Initialize git if not already initialized44    if not os.path.exists(".git"):45        print("๐Ÿ“ Initializing Git repository...")46        if not run_command("git init", "Git initialization"):47            return False48    49    # Check if there are any changes to commit50    result = subprocess.run("git status --porcelain", shell=True, capture_output=True, text=True)51    if not result.stdout.strip():52        print("โ„น๏ธ  No changes to commit.")53    else:54        print("๐Ÿ“‹ Changes detected:")55        print(result.stdout)56        57        # Add all files58        if not run_command("git add .", "Adding files to Git"):59            return False60        61        # Commit changes62        commit_message = input("Enter commit message (or press Enter for default): ").strip()63        if not commit_message:64            commit_message = "Update Agentic Browser for Hugging Face Spaces"65        66        if not run_command(f'git commit -m "{commit_message}"', "Committing changes"):67            return False68    69    print("\n๐ŸŽ‰ Repository is ready for deployment!")70    print("\n๐Ÿ“ Next steps:")71    print("1. Create a new Space on Hugging Face: https://huggingface.co/spaces")72    print("2. Choose:")73    print("   - SDK: Streamlit")74    print("   - Hardware: CPU basic (free) or upgrade as needed")75    print("3. Clone your Space repository:")76    print("   git clone https://huggingface.co/spaces/YOUR_USERNAME/SPACE_NAME")77    print("4. Copy all files from this directory to your Space directory")78    print("5. Push to Hugging Face:")79    print("   cd SPACE_NAME")80    print("   git add .")81    print("   git commit -m 'Initial deployment'")82    print("   git push origin main")83    84    # Ask if user wants to see deployment checklist85    show_checklist = input("\nWould you like to see the deployment checklist? (y/n): ").lower().startswith('y')86    87    if show_checklist:88        print("\n๐Ÿ“‹ Deployment Checklist:")89        print("โœ… All files are present and tested")90        print("โœ… Requirements.txt is optimized for HF Spaces")91        print("โœ… Import errors are fixed with fallbacks")92        print("โœ… Streamlit app is properly configured")93        print("โœ… Error handling is implemented")94        print("โœ… User interface is responsive")95        print("\n๐Ÿ”— Files included:")96        files = [97            "app.py - Main entry point",98            "requirements.txt - Python dependencies",99            "packages.txt - System packages",100            "README.md - Space description",101            "src/streamlit_app.py - UI components",102            "src/models/model_manager.py - Model handling",103            "config/ - Configuration files"104        ]105        for file in files:106            print(f"   ๐Ÿ“„ {file}")107    108    return True109 110if __name__ == "__main__":111    success = main()112    if success:113        print("\n๐ŸŽ‰ Ready for Hugging Face Spaces deployment!")114    else:115        print("\nโŒ Deployment preparation failed. Please fix the issues above.")116    sys.exit(0 if success else 1)