Skip to content

Commit 98fd1d9

Browse files
Kevin Turnerpsychedelicious
Kevin Turner
authored andcommitted
fix: make dev_reload work for files in nodes/
1 parent 6312e6a commit 98fd1d9

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

invokeai/app/run_app.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ def run_app() -> None:
4949
# Miscellaneous startup tasks.
5050
apply_monkeypatches()
5151
register_mime_types()
52-
if app_config.dev_reload:
53-
enable_dev_reload()
5452
check_cudnn(logger)
5553

5654
# Initialize the app and event loop.
@@ -61,6 +59,11 @@ def run_app() -> None:
6159
# core nodes have been imported so that we can catch when a custom node clobbers a core node.
6260
load_custom_nodes(custom_nodes_path=app_config.custom_nodes_path, logger=logger)
6361

62+
if app_config.dev_reload:
63+
# load_custom_nodes seems to bypass jurrigged's import sniffer, so be sure to call it *after* they're already
64+
# imported.
65+
enable_dev_reload(custom_nodes_path=app_config.custom_nodes_path)
66+
6467
# Start the server.
6568
config = uvicorn.Config(
6669
app=app,

invokeai/app/util/startup_utils.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
import mimetypes
33
import socket
4+
from pathlib import Path
45

56
import torch
67

@@ -33,8 +34,9 @@ def check_cudnn(logger: logging.Logger) -> None:
3334
)
3435

3536

36-
def enable_dev_reload() -> None:
37+
def enable_dev_reload(custom_nodes_path=None) -> None:
3738
"""Enable hot reloading on python file changes during development."""
39+
import invokeai
3840
from invokeai.backend.util.logging import InvokeAILogger
3941

4042
try:
@@ -44,7 +46,10 @@ def enable_dev_reload() -> None:
4446
'Can\'t start `--dev_reload` because jurigged is not found; `pip install -e ".[dev]"` to include development dependencies.'
4547
) from e
4648
else:
47-
jurigged.watch(logger=InvokeAILogger.get_logger(name="jurigged").info)
49+
paths = [str(Path(invokeai.__file__).with_name("*.py"))]
50+
if custom_nodes_path:
51+
paths.append(str(custom_nodes_path / "*.py"))
52+
jurigged.watch(pattern=paths, logger=InvokeAILogger.get_logger(name="jurigged").info)
4853

4954

5055
def apply_monkeypatches() -> None:

0 commit comments

Comments
 (0)