Spaces:
Running
Running
File size: 5,154 Bytes
6c914fc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
"""
Deployment Script for ProVerBs Landing Page
Deploys to Solomon7890/ProVerbS_LaW_mAiN_PAgE
"""
import subprocess
import sys
import os
def print_banner():
print("="*60)
print("π ProVerBs Legal AI - Landing Page Deployment")
print("="*60)
print()
def check_login():
"""Check if user is logged in to Hugging Face"""
print("π Checking Hugging Face authentication...")
try:
result = subprocess.run(['huggingface-cli', 'whoami'],
capture_output=True, text=True)
if result.returncode == 0:
username = result.stdout.strip().split('\n')[0].replace('username: ', '')
print(f" β
Logged in as: {username}")
return username
else:
print(" β Not logged in")
return None
except Exception as e:
print(f" β Error: {e}")
return None
def login_hf():
"""Login to Hugging Face"""
print("\nπ Please login to Hugging Face...")
print("Token: https://huggingface.co/settings/tokens\n")
try:
subprocess.run(['huggingface-cli', 'login'])
return check_login()
except Exception as e:
print(f"β Login failed: {e}")
return None
def deploy_space():
"""Deploy to the Space"""
space_name = "Solomon7890/ProVerbS_LaW_mAiN_PAgE"
print(f"\nπ€ Deploying to: {space_name}")
print("="*60)
try:
# Check if git is initialized
if not os.path.exists('.git'):
print("π¦ Initializing git repository...")
subprocess.run(['git', 'init'], check=True)
# Add remote if not exists
print("π Setting up remote...")
subprocess.run(
['git', 'remote', 'add', 'space', f'https://huggingface.co/spaces/{space_name}'],
capture_output=True
)
# Set remote URL (in case it already exists)
subprocess.run(
['git', 'remote', 'set-url', 'space', f'https://huggingface.co/spaces/{space_name}'],
capture_output=True
)
# Replace app.py with enhanced version
print("π Updating app.py with enhanced version...")
if os.path.exists('enhanced_app.py'):
import shutil
shutil.copy('enhanced_app.py', 'app.py')
print(" β
Enhanced app.py deployed")
# Add files
print("π Adding files...")
subprocess.run(['git', 'add', 'app.py', 'README.md', '.gitattributes'], check=True)
# Commit
print("πΎ Creating commit...")
subprocess.run(
['git', 'commit', '-m', 'Deploy enhanced ProVerBs Legal AI landing page'],
capture_output=True
)
# Push
print("π Pushing to Hugging Face...")
result = subprocess.run(
['git', 'push', 'space', 'main', '-f'],
capture_output=True,
text=True
)
if result.returncode != 0:
# Try master branch
result = subprocess.run(
['git', 'push', 'space', 'master', '-f'],
capture_output=True,
text=True
)
if "Everything up-to-date" in result.stderr or result.returncode == 0:
print(" β
Deployment successful!")
return True
else:
print(" β οΈ Push completed with warnings")
return True
except Exception as e:
print(f" β Error: {e}")
return False
def main():
print_banner()
# Check login
username = check_login()
if not username:
username = login_hf()
if not username:
print("\nβ Deployment cancelled - login required")
return
# Confirm deployment
space_url = "https://huggingface.co/spaces/Solomon7890/ProVerbS_LaW_mAiN_PAgE"
print(f"\nπ Deployment Target:")
print(f" Space: Solomon7890/ProVerbS_LaW_mAiN_PAgE")
print(f" URL: {space_url}")
print()
confirm = input("Deploy enhanced landing page now? (y/n): ").strip().lower()
if confirm != 'y':
print("\nβ Deployment cancelled")
return
# Deploy
if deploy_space():
print("\n" + "="*60)
print("β
DEPLOYMENT SUCCESSFUL!")
print("="*60)
print()
print(f"π Your Space is available at:")
print(f" {space_url}")
print()
print("β³ The Space is now building. This may take 2-3 minutes.")
print()
print("π Next steps:")
print(" 1. Visit your Space URL")
print(" 2. Wait for the build to complete")
print(" 3. Test all features")
print(" 4. Share with your audience!")
print()
print("="*60)
else:
print("\nβ Deployment failed. Please check the errors above.")
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\n\nβ Deployment cancelled by user")
except Exception as e:
print(f"\n\nβ Unexpected error: {e}")
|