Archived
Clean-slate rebuild. The previous entrypoint and modules (routes.py, workflows.py, imagelab_nodes.py, resources.py, etc.) are kept for reference as __init__.py.legacy + untouched files, not loaded. New surface: - hashing.py: SHA256 model hashing keyed by path relative to the models dir (no more bare-filename collisions). .index sidecars under model_index/. Maintains an in-memory index + ETag-style version token. - api.py: GET /imagelab/hashes serves the full cache from memory in one request, with ETag/If-None-Match -> 304 support. - __init__.py: registers the API and builds the hash index in a background thread on startup. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
"""
|
|
ImageLab v3 — ComfyUI custom node entrypoint.
|
|
|
|
This is a clean-slate rebuild. For now it does two things: hash all model
|
|
files on startup (in the background) and expose the hash cache over a small
|
|
HTTP API. Functionality will be added back in pieces.
|
|
|
|
The previous entrypoint is preserved as `__init__.py.legacy`, alongside the
|
|
other legacy modules (`routes.py`, `workflows.py`, `imagelab_nodes.py`,
|
|
`resources.py`, ...) — kept for reference, not loaded.
|
|
"""
|
|
import threading
|
|
|
|
from . import hashing
|
|
from . import api
|
|
|
|
# No custom nodes yet — ComfyUI still expects these symbols to exist.
|
|
NODE_CLASS_MAPPINGS = {}
|
|
NODE_DISPLAY_NAME_MAPPINGS = {}
|
|
|
|
# Register the HTTP API (synchronous — routes must exist before the server
|
|
# finishes starting; this is just dict insertion, it does not block).
|
|
api.setup_routes()
|
|
|
|
|
|
def _hash_on_startup():
|
|
print("[ImageLab] Building model-hash index in the background ...")
|
|
try:
|
|
counts = hashing.build_index()
|
|
if counts:
|
|
print(f"[ImageLab] Hashed: {counts}")
|
|
else:
|
|
print("[ImageLab] No new models to hash")
|
|
version, entries = hashing.get_snapshot()
|
|
print(f"[ImageLab] Index ready: {len(entries)} models (version {version})")
|
|
except Exception as e:
|
|
print(f"[ImageLab] Error during startup hashing: {e}")
|
|
|
|
|
|
threading.Thread(target=_hash_on_startup, daemon=True).start()
|
|
|
|
print("[ImageLab] v3 loaded")
|