Move load_custom_nodes() to run_app() entrypoint.

This commit is contained in:
Ryan Dick 2025-02-28 20:54:26 +00:00
commit 1e2c7c51b5
2 changed files with 6 additions and 6 deletions

View file

@ -28,7 +28,6 @@ from invokeai.app.api.routers import (
workflows,
)
from invokeai.app.api.sockets import SocketIO
from invokeai.app.invocations.load_custom_nodes import load_custom_nodes
from invokeai.app.services.config.config_default import get_config
from invokeai.app.util.custom_openapi import get_openapi_func
from invokeai.backend.util.logging import InvokeAILogger
@ -38,11 +37,6 @@ logger = InvokeAILogger.get_logger(config=app_config)
loop = asyncio.new_event_loop()
# Load custom nodes. This must be done after importing the Graph class, which itself imports all modules from the
# invocations module. The ordering here is implicit, but important - we want to load custom nodes after all the
# core nodes have been imported so that we can catch when a custom node clobbers a core node.
load_custom_nodes(custom_nodes_path=app_config.custom_nodes_path)
@asynccontextmanager
async def lifespan(app: FastAPI):

View file

@ -1,5 +1,6 @@
import uvicorn
from invokeai.app.invocations.load_custom_nodes import load_custom_nodes
from invokeai.app.services.config.config_default import get_config
from invokeai.app.util.startup_utils import (
apply_monkeypatches,
@ -47,6 +48,11 @@ def run_app() -> None:
# Initialize the app and event loop.
app, loop = get_app()
# Load custom nodes. This must be done after importing the Graph class, which itself imports all modules from the
# invocations module. The ordering here is implicit, but important - we want to load custom nodes after all the
# core nodes have been imported so that we can catch when a custom node clobbers a core node.
load_custom_nodes(custom_nodes_path=app_config.custom_nodes_path)
# Start the server.
config = uvicorn.Config(
app=app,