Spaces:
Runtime error
Runtime error
File size: 3,082 Bytes
77a06d0 |
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 |
"""
Setup script for DReamMachine
Helps verify installation and configuration
"""
import os
import sys
from pathlib import Path
def check_python_version():
"""Verify Python version is 3.9+"""
if sys.version_info < (3, 9):
print("β Python 3.9 or higher required")
print(f" Current version: {sys.version}")
return False
print(f"β Python version: {sys.version.split()[0]}")
return True
def check_dependencies():
"""Check if required packages are installed"""
required = [
'huggingface_hub',
'datasets',
'gradio',
'yaml'
]
missing = []
for package in required:
try:
__import__(package)
print(f"β {package} installed")
except ImportError:
print(f"β {package} not found")
missing.append(package)
if missing:
print("\nTo install missing packages:")
print(" pip install -r requirements.txt")
return False
return True
def check_config_file():
"""Verify config.yaml exists"""
if Path("config.yaml").exists():
print("β config.yaml found")
return True
else:
print("β config.yaml not found")
return False
def check_hf_token():
"""Check if HuggingFace token is configured"""
if os.getenv('HF_TOKEN'):
print("β HF_TOKEN environment variable set")
return True
elif Path('.env').exists():
with open('.env', 'r') as f:
if 'HF_TOKEN' in f.read():
print("β HF_TOKEN found in .env file")
return True
print("β HF_TOKEN not found")
print(" Set HF_TOKEN environment variable or add to .env file")
print(" Get your token from: https://huggingface.co/settings/tokens")
return False
def create_logs_directory():
"""Create logs directory if it doesn't exist"""
Path("logs").mkdir(exist_ok=True)
print("β logs directory ready")
return True
def main():
"""Run all setup checks"""
print("=" * 60)
print("DReamMachine Setup Verification")
print("=" * 60)
print()
checks = [
("Python Version", check_python_version),
("Dependencies", check_dependencies),
("Configuration File", check_config_file),
("HuggingFace Token", check_hf_token),
("Logs Directory", create_logs_directory)
]
results = []
for name, check_func in checks:
print(f"\nChecking {name}...")
results.append(check_func())
print("\n" + "=" * 60)
if all(results):
print("β All checks passed! You're ready to run DReamMachine.")
print("\nTo start the Gradio interface:")
print(" python app.py")
print("\nTo run from CLI:")
print(" python run_cli.py --single")
print("\nFor more options:")
print(" python run_cli.py --help")
else:
print("β Some checks failed. Please fix the issues above.")
return 1
print("=" * 60)
return 0
if __name__ == '__main__':
exit(main())
|