mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(dev_reload): use jurigged to hot reload changes to Python source
This commit is contained in:
parent
498d2ecc2b
commit
654dcd453f
@ -1,12 +1,12 @@
|
|||||||
# Copyright (c) 2022-2023 Kyle Schouviller (https://github.com/kyle0654) and the InvokeAI Team
|
# Copyright (c) 2022-2023 Kyle Schouviller (https://github.com/kyle0654) and the InvokeAI Team
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import logging
|
||||||
|
import socket
|
||||||
import sys
|
import sys
|
||||||
from inspect import signature
|
from inspect import signature
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import logging
|
|
||||||
import uvicorn
|
import uvicorn
|
||||||
import socket
|
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html
|
from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html
|
||||||
@ -14,7 +14,6 @@ from fastapi.openapi.utils import get_openapi
|
|||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
from fastapi_events.handlers.local import local_handler
|
from fastapi_events.handlers.local import local_handler
|
||||||
from fastapi_events.middleware import EventHandlerASGIMiddleware
|
from fastapi_events.middleware import EventHandlerASGIMiddleware
|
||||||
from pathlib import Path
|
|
||||||
from pydantic.schema import schema
|
from pydantic.schema import schema
|
||||||
|
|
||||||
# This should come early so that modules can log their initialization properly
|
# This should come early so that modules can log their initialization properly
|
||||||
@ -42,9 +41,12 @@ from .invocations.baseinvocation import BaseInvocation, _InputField, _OutputFiel
|
|||||||
|
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
import invokeai.backend.util.hotfixes
|
import invokeai.backend.util.hotfixes
|
||||||
|
|
||||||
if torch.backends.mps.is_available():
|
if torch.backends.mps.is_available():
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
import invokeai.backend.util.mps_fixes
|
import invokeai.backend.util.mps_fixes
|
||||||
|
|
||||||
# fix for windows mimetypes registry entries being borked
|
# fix for windows mimetypes registry entries being borked
|
||||||
@ -213,6 +215,17 @@ def invoke_api():
|
|||||||
|
|
||||||
check_invokeai_root(app_config) # note, may exit with an exception if root not set up
|
check_invokeai_root(app_config) # note, may exit with an exception if root not set up
|
||||||
|
|
||||||
|
if app_config.dev_reload:
|
||||||
|
try:
|
||||||
|
import jurigged
|
||||||
|
except ImportError as e:
|
||||||
|
logger.error(
|
||||||
|
"Can't start `--dev_reload` because jurigged is not found; `pip install -e '.[dev]'` to include development dependencies.",
|
||||||
|
exc_info=e,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
jurigged.watch(logger=InvokeAILogger.getLogger(name="jurigged").info)
|
||||||
|
|
||||||
port = find_port(app_config.port)
|
port = find_port(app_config.port)
|
||||||
if port != app_config.port:
|
if port != app_config.port:
|
||||||
logger.warn(f"Port {app_config.port} in use, using port {port}")
|
logger.warn(f"Port {app_config.port} in use, using port {port}")
|
||||||
|
@ -159,15 +159,17 @@ two configs are kept in separate sections of the config file:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import pydoc
|
|
||||||
import os
|
import os
|
||||||
|
import pydoc
|
||||||
import sys
|
import sys
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from omegaconf import OmegaConf, DictConfig, ListConfig
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import ClassVar, Dict, List, Literal, Union, get_origin, get_type_hints, get_args
|
||||||
|
|
||||||
|
from omegaconf import OmegaConf, DictConfig, ListConfig
|
||||||
from pydantic import BaseSettings, Field, parse_obj_as
|
from pydantic import BaseSettings, Field, parse_obj_as
|
||||||
from typing import ClassVar, Dict, List, Set, Literal, Union, get_origin, get_type_hints, get_args
|
|
||||||
|
|
||||||
INIT_FILE = Path("invokeai.yaml")
|
INIT_FILE = Path("invokeai.yaml")
|
||||||
DB_FILE = Path("invokeai.db")
|
DB_FILE = Path("invokeai.db")
|
||||||
@ -418,6 +420,8 @@ class InvokeAIAppConfig(InvokeAISettings):
|
|||||||
log_format : Literal[tuple(['plain','color','syslog','legacy'])] = Field(default="color", description='Log format. Use "plain" for text-only, "color" for colorized output, "legacy" for 2.3-style logging and "syslog" for syslog-style', category="Logging")
|
log_format : Literal[tuple(['plain','color','syslog','legacy'])] = Field(default="color", description='Log format. Use "plain" for text-only, "color" for colorized output, "legacy" for 2.3-style logging and "syslog" for syslog-style', category="Logging")
|
||||||
log_level : Literal[tuple(["debug","info","warning","error","critical"])] = Field(default="info", description="Emit logging messages at this level or higher", category="Logging")
|
log_level : Literal[tuple(["debug","info","warning","error","critical"])] = Field(default="info", description="Emit logging messages at this level or higher", category="Logging")
|
||||||
|
|
||||||
|
dev_reload : bool = Field(default=False, description="Automatically reload when Python sources are changed.", category="Development")
|
||||||
|
|
||||||
version : bool = Field(default=False, description="Show InvokeAI version and exit", category="Other")
|
version : bool = Field(default=False, description="Show InvokeAI version and exit", category="Other")
|
||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
|
@ -93,6 +93,7 @@ dependencies = [
|
|||||||
"mkdocs-redirects==1.2.0",
|
"mkdocs-redirects==1.2.0",
|
||||||
]
|
]
|
||||||
"dev" = [
|
"dev" = [
|
||||||
|
"jurigged",
|
||||||
"pudb",
|
"pudb",
|
||||||
]
|
]
|
||||||
"test" = ["pytest>6.0.0", "pytest-cov", "pytest-datadir", "black"]
|
"test" = ["pytest>6.0.0", "pytest-cov", "pytest-datadir", "black"]
|
||||||
|
Loading…
Reference in New Issue
Block a user