chore: 🧹 support hot reloading
This commit is contained in:
@@ -13,3 +13,4 @@ node.zip
|
||||
|
||||
# I store the gh-pages worktrees (src & build) there
|
||||
.worktrees
|
||||
comfy.lock
|
||||
|
||||
+26
-8
@@ -34,6 +34,8 @@ from aiohttp import web
|
||||
|
||||
IN_COMFY = False
|
||||
|
||||
PromptServer = None
|
||||
|
||||
try:
|
||||
from server import PromptServer
|
||||
|
||||
@@ -240,10 +242,29 @@ if failed:
|
||||
# - ENDPOINT
|
||||
|
||||
|
||||
if IN_COMFY and hasattr(PromptServer, "instance"):
|
||||
# TODO: move that away and simplify existing endpoints
|
||||
|
||||
|
||||
def register_routes():
|
||||
if not PromptServer:
|
||||
log.error("No prompt server, are you inside comfy?")
|
||||
|
||||
if PromptServer.instance.app.frozen:
|
||||
log.warning(
|
||||
"The router is frozen and cannot be further edited."
|
||||
"If you are hot reloading mtb this is expected."
|
||||
)
|
||||
return
|
||||
|
||||
img_cache = None
|
||||
prompt_cache = None
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
from io import BytesIO
|
||||
|
||||
from PIL import Image
|
||||
|
||||
with contextlib.suppress(ImportError):
|
||||
from cachetools import TTLCache
|
||||
|
||||
@@ -360,13 +381,6 @@ if IN_COMFY and hasattr(PromptServer, "instance"):
|
||||
# Return JSON for other requests
|
||||
return web.json_response({"message": "Welcome to MTB!"})
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
from io import BytesIO
|
||||
|
||||
from aiohttp import web
|
||||
from PIL import Image
|
||||
|
||||
def get_cached_image(file_path: str, preview_params=None, channel=None):
|
||||
cache_key = (file_path, preview_params, channel)
|
||||
if img_cache and (cache_key in img_cache):
|
||||
@@ -571,6 +585,10 @@ if IN_COMFY and hasattr(PromptServer, "instance"):
|
||||
return await endpoint.do_action(request)
|
||||
|
||||
|
||||
if IN_COMFY and hasattr(PromptServer, "instance"):
|
||||
register_routes()
|
||||
|
||||
|
||||
# - WAS Dictionary
|
||||
MANIFEST = {
|
||||
"name": "MTB Nodes", # The title that will be displayed on Node Class menu,. and Node Class view
|
||||
|
||||
Reference in New Issue
Block a user