Skip to content

fix: make dev_reload work for files in nodes/ #7819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions invokeai/app/run_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ def run_app() -> None:
# Miscellaneous startup tasks.
apply_monkeypatches()
register_mime_types()
if app_config.dev_reload:
enable_dev_reload()
check_cudnn(logger)

# Initialize the app and event loop.
Expand All @@ -61,6 +59,11 @@ def run_app() -> None:
# 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, logger=logger)

if app_config.dev_reload:
# load_custom_nodes seems to bypass jurrigged's import sniffer, so be sure to call it *after* they're already
# imported.
enable_dev_reload(custom_nodes_path=app_config.custom_nodes_path)

# Start the server.
config = uvicorn.Config(
app=app,
Expand Down
9 changes: 7 additions & 2 deletions invokeai/app/util/startup_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import mimetypes
import socket
from pathlib import Path

import torch

Expand Down Expand Up @@ -33,8 +34,9 @@ def check_cudnn(logger: logging.Logger) -> None:
)


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

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


def apply_monkeypatches() -> None:
Expand Down