- Autonomous generation of remaining 384 assets - 60s rate limiting between assets - Auto-commits every 20 assets - Estimated 6.4 hours runtime - Full documentation in OVERNIGHT_GENERATION.md Ready to run: nohup python3 scripts/generate_overnight.py > overnight_production.log 2>&1 &
113 lines
3.7 KiB
Python
Executable File
113 lines
3.7 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
🌙 OVERNIGHT PRODUCTION - Automated Asset Generation
|
|
Generates remaining 384 assets slowly with rate limiting
|
|
Runs autonomously in background
|
|
"""
|
|
import time
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Add scripts to path
|
|
sys.path.insert(0, '/Users/davidkotnik/repos/novafarma/scripts')
|
|
from generate_v7_final import generate_registry, generate_image_google, setup_google_ai, OUTPUT_DIR
|
|
|
|
# Configuration
|
|
BATCH_SIZE = 1 # Generate 1 at a time to avoid rate limits
|
|
WAIT_BETWEEN = 60 # 60 seconds between each asset
|
|
COMMIT_EVERY = 20 # Git commit every 20 assets
|
|
|
|
def main():
|
|
print("=" * 70)
|
|
print("🌙 OVERNIGHT ASSET PRODUCTION")
|
|
print("=" * 70)
|
|
|
|
# Setup API
|
|
if not setup_google_ai():
|
|
print("❌ API key not configured")
|
|
return
|
|
|
|
print("✅ API configured\n")
|
|
|
|
# Load registry
|
|
print("📋 Loading asset registry...")
|
|
ASSETS = generate_registry()
|
|
print(f"📊 Total registry: {len(ASSETS)} assets\n")
|
|
|
|
# Filter only missing assets
|
|
missing = [a for a in ASSETS if not (OUTPUT_DIR / a["cat"] / a["file"]).exists()]
|
|
print(f"🎯 Missing: {len(missing)} assets")
|
|
print(f"✅ Existing: {len(ASSETS) - len(missing)} assets\n")
|
|
|
|
if not missing:
|
|
print("🎉 All assets already generated!")
|
|
return
|
|
|
|
print(f"⏰ Estimated time: {len(missing) * WAIT_BETWEEN // 3600} hours\n")
|
|
print("🚀 STARTING OVERNIGHT PRODUCTION...\n")
|
|
|
|
success, fail = 0, 0
|
|
commit_counter = 0
|
|
|
|
for i, asset in enumerate(missing, 1):
|
|
path = OUTPUT_DIR / asset["cat"] / asset["file"]
|
|
|
|
print(f"[{i}/{len(missing)}] 🎨 {asset['file']}")
|
|
|
|
try:
|
|
if generate_image_google(asset["prompt"], path):
|
|
print(f" ✅ SAVED to {asset['cat']}/")
|
|
success += 1
|
|
commit_counter += 1
|
|
|
|
# Auto-commit every N assets
|
|
if commit_counter >= COMMIT_EVERY:
|
|
import subprocess
|
|
subprocess.run([
|
|
"git", "-C", "/Users/davidkotnik/repos/novafarma",
|
|
"add", "assets/images/"
|
|
])
|
|
subprocess.run([
|
|
"git", "-C", "/Users/davidkotnik/repos/novafarma",
|
|
"commit", "-m",
|
|
f"🌙 Overnight batch: {success} assets ({success}/{len(missing)})"
|
|
])
|
|
print(f"\n💾 Git commit: {success} assets saved\n")
|
|
commit_counter = 0
|
|
else:
|
|
print(f" ❌ FAILED")
|
|
fail += 1
|
|
except Exception as e:
|
|
print(f" ⚠️ ERROR: {e}")
|
|
fail += 1
|
|
|
|
# Progress report every 10
|
|
if i % 10 == 0:
|
|
print(f"\n📊 Progress: {i}/{len(missing)} | ✅{success} ❌{fail}\n")
|
|
|
|
# Rate limiting pause
|
|
if i < len(missing): # Don't wait after last one
|
|
print(f" ⏳ Waiting {WAIT_BETWEEN}s...")
|
|
time.sleep(WAIT_BETWEEN)
|
|
|
|
# Final commit
|
|
if commit_counter > 0:
|
|
import subprocess
|
|
subprocess.run([
|
|
"git", "-C", "/Users/davidkotnik/repos/novafarma",
|
|
"add", "assets/images/"
|
|
])
|
|
subprocess.run([
|
|
"git", "-C", "/Users/davidkotnik/repos/novafarma",
|
|
"commit", "-m",
|
|
f"🎉 Overnight complete: {success} total assets"
|
|
])
|
|
|
|
print("\n" + "=" * 70)
|
|
print("🎉 OVERNIGHT PRODUCTION COMPLETE!")
|
|
print(f"✅ Success: {success} | ❌ Fail: {fail}")
|
|
print("=" * 70)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|