updates UI

This commit is contained in:
mike
2026-07-01 03:46:10 +02:00
parent 145fa686e4
commit 970daeba31
5 changed files with 470 additions and 7 deletions

View File

@@ -442,7 +442,8 @@ def _idle_turntable_daemon():
prompt=prompt,
source_refs=json.dumps([preferred_fname]),
sort_order=200 + angle_idx,
pose=f"Orbit {int(deg)}°"
pose=f"Orbit {int(deg)}°",
tags=["ORBIT"]
)
_update_cached_file_meta(vname, exists=True)
except Exception as db_err:
@@ -1551,6 +1552,47 @@ def _write_all_static() -> None:
# Update car.html PRELOADED_IMAGES
_sync_preloaded_images()
# Group-specific JSON and HTML generation
car_html_src = os.path.join(_HERE, "car.html")
template_content = ""
if os.path.exists(car_html_src):
try:
with open(car_html_src, "r", encoding="utf-8") as f:
template_content = f.read()
except Exception as template_err:
print(f"[static] Error reading car.html template: {template_err}")
# Extract unique group IDs from db_images
gids = set(p["group_id"] for p in db_images if p.get("group_id"))
for gid in gids:
if not gid:
continue
# Sanitize the group_id to prevent directory traversal / invalid characters in filenames
sanitized_gid = re.sub(r'[^a-zA-Z0-9_\-]', '_', gid)
# Filter images belonging to this group
group_images = [p for p in db_images if p.get("group_id") == gid]
# Write group json data: _data/group_{sanitized_gid}.json
group_json_path = os.path.join(data_dir, f"group_{sanitized_gid}.json")
_write_json(group_json_path, {"images": group_images})
# Write shoot specific html: shoot_{sanitized_gid}.html next to car.html
if template_content:
# Replace `const LOAD_ONLY_GROUP_ID = null;` with `const LOAD_ONLY_GROUP_ID = '{gid}';`
escaped_gid = gid.replace("'", "\\'").replace('"', '\\"')
replaced_content = template_content.replace(
"const LOAD_ONLY_GROUP_ID = null;",
f"const LOAD_ONLY_GROUP_ID = '{escaped_gid}';"
)
group_html_path = os.path.join(output_dir, f"shoot_{sanitized_gid}.html")
try:
with open(group_html_path, "w", encoding="utf-8") as f:
f.write(replaced_content)
except Exception as html_err:
print(f"[static] Error writing group html for {gid}: {html_err}")
except Exception as e:
print(f"[static] write_all error: {e}")
@@ -3396,6 +3438,54 @@ def health():
raise HTTPException(503, f"ComfyUI unreachable at {COMFY}: {e}")
@app.get("/services/status")
def get_services_status():
comfy_online = False
comfy_busy = False
# 1. Check ComfyUI Model-Engine
try:
r = requests.get(f"{COMFY}/system_stats", timeout=1.0)
if r.status_code == 200:
comfy_online = True
# Check if there are active queue items in ComfyUI
try:
qr = requests.get(f"{COMFY}/queue", timeout=1.0)
if qr.status_code == 200:
qj = qr.json()
running = qj.get("queue_running", [])
pending = qj.get("queue_pending", [])
if running or pending:
comfy_busy = True
except Exception:
pass
except Exception:
pass
# 2. Check if backend is busy with its own tasks
backend_busy = False
for jid, job in jobs.items():
if job.get("status") == "running":
backend_busy = True
break
# Or is turntable active?
if _idle_turntable_busy:
backend_busy = True
comfy_busy = True # Since turntable runs on ComfyUI
return {
"backend": {
"online": True,
"busy": backend_busy
},
"model_engine": {
"online": comfy_online,
"busy": comfy_busy
}
}
@app.get("/privacy/status")
def get_privacy_status():
return {"locked": _privacy_locked}
@@ -6363,7 +6453,8 @@ def _create_qwen_orbit(req: OrbitRequest, output_dir: str, img_path: str) -> dic
prompt=yaw_prompt(v["deg"]),
source_refs=json.dumps([req.filename]),
sort_order=200 + angle_idx,
pose=f"Orbit {int(v['deg'])}°"
pose=f"Orbit {int(v['deg'])}°",
tags=["ORBIT"]
)
except Exception as db_err:
print(f"[orbit-qwen] DB frame error: {db_err}")