🐛 Fix overnight generator bug - properly import generate_assets_full module

This commit is contained in:
2025-12-29 09:08:17 +01:00
parent 7dc9569772
commit f0eafa5332

View File

@@ -7,7 +7,6 @@ Z avtomatskim Git commitom in progress trackingom
import os
import sys
import json
import time
import uuid
import requests
@@ -37,10 +36,8 @@ def log(msg):
line = f"[{ts}] {msg}"
print(line)
sys.stdout.flush()
# Also write to progress log
with open(PROGRESS_LOG, 'a') as f:
f.write(line + "\\n")
f.write(line + "\n")
def git_commit(file_path, category, name):
try:
@@ -51,18 +48,15 @@ def git_commit(file_path, category, name):
except:
return False
# Load FULL registry from existing script
# Load FULL registry safely
sys.path.insert(0, str(REPO_DIR / "scripts"))
exec(open(REPO_DIR / "scripts/generate_assets_full.py").read().replace('if __name__', 'if False'))
# Get all assets EXCEPT NPCs
ALL_ASSETS = generate_registry()
import generate_assets_full
ALL_ASSETS = generate_assets_full.generate_registry()
FILTERED_ASSETS = [a for a in ALL_ASSETS if a['cat'] != 'npcs']
def create_workflow(prompt_text, output_name, size=512):
seed = int(time.time() * 1000) % 2147483647
full_prompt = f"{STYLE}, {prompt_text}"
return {
"1": {"class_type": "CheckpointLoaderSimple", "inputs": {"ckpt_name": "dreamshaper_8.safetensors"}},
"2": {"class_type": "EmptyLatentImage", "inputs": {"width": size, "height": size, "batch_size": 1}},
@@ -91,7 +85,7 @@ def queue_prompt(workflow):
def wait_completion(prompt_id, timeout=120):
start = time.time()
while time.time() - start < timeout:
while time.time() < start + timeout:
try:
r = requests.get(f"{COMFYUI_URL}/history/{prompt_id}", timeout=5)
if prompt_id in r.json() and r.json()[prompt_id].get("outputs"):
@@ -120,11 +114,10 @@ def download_and_process(prompt_id, output_path):
def main():
log("="*70)
log("🌙 NOČNA GENERACIJA - FULL Asset Set")
log("🌙 DAYTIME GENERATION - FULL Asset Set")
log(" BREZ NPCs in glavnih karakterjev")
log("="*70)
# Check ComfyUI
try:
r = requests.get(f"{COMFYUI_URL}/system_stats", timeout=5)
log(f"✅ ComfyUI v{r.json()['system']['comfyui_version']}")
@@ -132,21 +125,19 @@ def main():
log("❌ ComfyUI not running!")
return
log(f"\\n📊 Registry Statistics:")
log(f"\n📊 Registry Statistics:")
log(f" Total assets: {len(ALL_ASSETS)}")
log(f" NPCs (excluded): {len([a for a in ALL_ASSETS if a['cat'] == 'npcs'])}")
log(f" FILTERED (to generate): {len(FILTERED_ASSETS)}")
# Count existing
existing = sum(1 for a in FILTERED_ASSETS if (OUTPUT_DIR / a['cat'] / a['file']).exists())
to_generate = len(FILTERED_ASSETS) - existing
log(f"\\n📁 File Status:")
log(f"\n📁 File Status:")
log(f" Already exist: {existing}")
log(f" To generate: {to_generate}")
# Category breakdown
log(f"\\n📦 By Category:")
log(f"\n📦 By Category:")
cats = {}
for a in FILTERED_ASSETS:
cats[a['cat']] = cats.get(a['cat'], 0) + 1
@@ -155,11 +146,11 @@ def main():
log(f" {cat:20s}: {count:4d} total ({existing_cat} exist, {count-existing_cat} to gen)")
if to_generate == 0:
log("\\n✅ All assets already generated!")
log("\n✅ All assets already generated!")
return
log(f"\\n🚀 Starting generation of {to_generate} assets...")
log(f" ETA: ~{to_generate * 20 / 3600:.1f} hours\\n")
log(f"\n🚀 Starting generation of {to_generate} assets...")
log(f" ETA: ~{to_generate * 20 / 3600:.1f} hours\n")
success, skip, fail = 0, 0, 0
start_time = time.time()
@@ -175,37 +166,34 @@ def main():
log(f"[{i}/{len(FILTERED_ASSETS)}] 🎨 {asset['cat']}/{asset['file'][:40]}")
# Boss size larger
size = 768 if asset['cat'] == 'bosses' else 512
wf = create_workflow(asset['prompt'], asset['file'].replace('.png', ''), size)
pid = queue_prompt(wf)
if pid and wait_completion(pid) and download_and_process(pid, path):
log(f" ✅ Done | Auto-committed")
log(f" ✅ Done")
git_commit(path, asset['cat'], asset['file'])
success += 1
else:
log(f" ❌ FAILED")
fail += 1
# Progress update every 10
if i % 10 == 0:
elapsed = time.time() - start_time
per_asset = elapsed / (success + fail) if (success + fail) > 0 else 20
remaining = per_asset * (to_generate - success - fail)
log(f"\\n📊 [{i}/{len(FILTERED_ASSETS)}] ✅{success} ⏭️ {skip}{fail}")
log(f" ⏱️ Elapsed: {elapsed/60:.1f}m | ETA: {remaining/60:.1f}m\\n")
log(f"\n📊 [{i}/{len(FILTERED_ASSETS)}] ✅{success} ⏭️ {skip}{fail}")
log(f" ⏱️ Elapsed: {elapsed/60:.1f}m | ETA: {remaining/60:.1f}m\n")
elapsed = time.time() - start_time
log("\\n" + "="*70)
log("🌙 NOČNA GENERACIJA COMPLETE!")
log("\n" + "="*70)
log("🎨 GENERATION COMPLETE!")
log(f" ✅ Success: {success}")
log(f" ⏭️ Skipped: {skip}")
log(f" ❌ Failed: {fail}")
log(f" ⏱️ Total time: {elapsed/3600:.1f} hours")
log(f" 📁 Output: {OUTPUT_DIR}")
log("="*70)
log("\\n💤 Lahko greste spat - vse je avtomatsko!")
if __name__ == "__main__":
main()