Spaces:
Build error
Build error
File size: 4,251 Bytes
09fa60b |
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 |
#!/usr/bin/env python3
"""Verify AudioForge backend setup."""
import sys
from pathlib import Path
# Fix Windows console encoding
if sys.platform == "win32":
import io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
def check_python_version():
"""Check Python version."""
if sys.version_info < (3, 11):
print("[ERROR] Python 3.11+ required")
print(f" Current version: {sys.version}")
return False
print(f"[OK] Python version: {sys.version.split()[0]}")
return True
def check_dependencies():
"""Check if dependencies are installed."""
required_packages = [
"fastapi",
"uvicorn",
"pydantic",
"sqlalchemy",
"structlog",
"torch",
"librosa",
]
missing = []
for package in required_packages:
try:
__import__(package)
except ImportError:
missing.append(package)
if missing:
print(f"[ERROR] Missing packages: {', '.join(missing)}")
print(" Run: uv pip install -e '.[dev]'")
return False
print("[OK] All required packages installed")
return True
def check_env_file():
"""Check if .env file exists."""
env_path = Path(".env")
env_example = Path(".env.example")
if not env_path.exists():
if env_example.exists():
print("[WARN] .env file not found")
print(" Creating .env from .env.example...")
import shutil
shutil.copy(env_example, env_path)
print("[OK] .env file created (please review and configure)")
return True
else:
print("[ERROR] .env.example not found")
return False
print("[OK] .env file exists")
return True
def check_storage_dirs():
"""Check if storage directories exist."""
storage_path = Path("storage/audio")
required_dirs = ["music", "vocals", "mixed", "mastered"]
missing = []
for subdir in required_dirs:
dir_path = storage_path / subdir
if not dir_path.exists():
missing.append(str(dir_path))
if missing:
print(f"[WARN] Missing storage directories:")
for d in missing:
print(f" {d}")
print(" Creating directories...")
for d in missing:
Path(d).mkdir(parents=True, exist_ok=True)
print("[OK] Storage directories created")
else:
print("[OK] Storage directories exist")
return True
def check_database_config():
"""Check database configuration."""
try:
from app.core.config import settings
db_url = settings.DATABASE_URL
if "postgresql" in db_url:
print("[OK] Database URL configured")
return True
else:
print("[WARN] Database URL may be incorrect")
return False
except ImportError as e:
print(f"[WARN] Cannot check config (dependencies not installed): {e}")
print(" Install dependencies first: uv pip install -e '.[dev]'")
return False
except Exception as e:
print(f"[ERROR] Error loading config: {e}")
return False
def main():
"""Run all checks."""
print("AudioForge Backend Setup Verification")
print("=" * 50)
print()
checks = [
("Python Version", check_python_version),
("Dependencies", check_dependencies),
("Environment File", check_env_file),
("Storage Directories", check_storage_dirs),
("Database Config", check_database_config),
]
results = []
for name, check_func in checks:
print(f"\n{name}:")
result = check_func()
results.append(result)
print("\n" + "=" * 50)
if all(results):
print("[OK] All checks passed! Ready to run.")
return 0
else:
print("[ERROR] Some checks failed. Please fix issues above.")
return 1
if __name__ == "__main__":
sys.exit(main())
|