feat: add SQLite stats database layer for CivitAI stats
Implements StatsDB class with upsert, batch upsert, get_by_hashes, get_all, count, and close methods backed by a WAL-mode SQLite database. Also guards __init__.py relative imports behind __package__ check so pytest can run without ComfyUI context, and removes empty tests/__init__.py to prevent pytest Package collector from traversing into the plugin root. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+34
-30
@@ -19,38 +19,42 @@ import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# ── Import node classes ────────────────────────────────────────────────
|
||||
from .nodes.lora_loader import LoraLoaderRemoteLM, LoraTextLoaderRemoteLM
|
||||
from .nodes.lora_stacker import LoraStackerRemoteLM
|
||||
from .nodes.lora_randomizer import LoraRandomizerRemoteLM
|
||||
from .nodes.lora_cycler import LoraCyclerRemoteLM
|
||||
from .nodes.lora_pool import LoraPoolRemoteLM
|
||||
from .nodes.save_image import SaveImageRemoteLM
|
||||
from .nodes.wanvideo import WanVideoLoraSelectRemoteLM, WanVideoLoraTextSelectRemoteLM
|
||||
# Guard relative imports: only execute when loaded as a proper package
|
||||
# (i.e. inside ComfyUI). Skipped when the file is imported standalone by
|
||||
# pytest or other tools that add the directory directly to sys.path.
|
||||
if __package__:
|
||||
# ── Import node classes ────────────────────────────────────────────────
|
||||
from .nodes.lora_loader import LoraLoaderRemoteLM, LoraTextLoaderRemoteLM
|
||||
from .nodes.lora_stacker import LoraStackerRemoteLM
|
||||
from .nodes.lora_randomizer import LoraRandomizerRemoteLM
|
||||
from .nodes.lora_cycler import LoraCyclerRemoteLM
|
||||
from .nodes.lora_pool import LoraPoolRemoteLM
|
||||
from .nodes.save_image import SaveImageRemoteLM
|
||||
from .nodes.wanvideo import WanVideoLoraSelectRemoteLM, WanVideoLoraTextSelectRemoteLM
|
||||
|
||||
# ── NODE_CLASS_MAPPINGS (how ComfyUI discovers nodes) ──────────────────
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
LoraLoaderRemoteLM.NAME: LoraLoaderRemoteLM,
|
||||
LoraTextLoaderRemoteLM.NAME: LoraTextLoaderRemoteLM,
|
||||
LoraStackerRemoteLM.NAME: LoraStackerRemoteLM,
|
||||
LoraRandomizerRemoteLM.NAME: LoraRandomizerRemoteLM,
|
||||
LoraCyclerRemoteLM.NAME: LoraCyclerRemoteLM,
|
||||
LoraPoolRemoteLM.NAME: LoraPoolRemoteLM,
|
||||
SaveImageRemoteLM.NAME: SaveImageRemoteLM,
|
||||
WanVideoLoraSelectRemoteLM.NAME: WanVideoLoraSelectRemoteLM,
|
||||
WanVideoLoraTextSelectRemoteLM.NAME: WanVideoLoraTextSelectRemoteLM,
|
||||
}
|
||||
# ── NODE_CLASS_MAPPINGS (how ComfyUI discovers nodes) ──────────────────
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
LoraLoaderRemoteLM.NAME: LoraLoaderRemoteLM,
|
||||
LoraTextLoaderRemoteLM.NAME: LoraTextLoaderRemoteLM,
|
||||
LoraStackerRemoteLM.NAME: LoraStackerRemoteLM,
|
||||
LoraRandomizerRemoteLM.NAME: LoraRandomizerRemoteLM,
|
||||
LoraCyclerRemoteLM.NAME: LoraCyclerRemoteLM,
|
||||
LoraPoolRemoteLM.NAME: LoraPoolRemoteLM,
|
||||
SaveImageRemoteLM.NAME: SaveImageRemoteLM,
|
||||
WanVideoLoraSelectRemoteLM.NAME: WanVideoLoraSelectRemoteLM,
|
||||
WanVideoLoraTextSelectRemoteLM.NAME: WanVideoLoraTextSelectRemoteLM,
|
||||
}
|
||||
|
||||
# ── WEB_DIRECTORY tells ComfyUI where to find our JS extensions ───────
|
||||
WEB_DIRECTORY = "./web/comfyui"
|
||||
# ── WEB_DIRECTORY tells ComfyUI where to find our JS extensions ───────
|
||||
WEB_DIRECTORY = "./web/comfyui"
|
||||
|
||||
# ── Register proxy middleware ──────────────────────────────────────────
|
||||
try:
|
||||
from server import PromptServer # type: ignore
|
||||
from .proxy import register_proxy
|
||||
# ── Register proxy middleware ──────────────────────────────────────────
|
||||
try:
|
||||
from server import PromptServer # type: ignore
|
||||
from .proxy import register_proxy
|
||||
|
||||
register_proxy(PromptServer.instance.app)
|
||||
except Exception as exc:
|
||||
logger.warning("[LM-Remote] Could not register proxy middleware: %s", exc)
|
||||
register_proxy(PromptServer.instance.app)
|
||||
except Exception as exc:
|
||||
logger.warning("[LM-Remote] Could not register proxy middleware: %s", exc)
|
||||
|
||||
__all__ = ["NODE_CLASS_MAPPINGS", "WEB_DIRECTORY"]
|
||||
__all__ = ["NODE_CLASS_MAPPINGS", "WEB_DIRECTORY"]
|
||||
|
||||
Reference in New Issue
Block a user