use logger in ApiDependencies

This commit is contained in:
Lincoln Stein 2023-05-01 16:27:44 -04:00
parent 0bc2edc044
commit b050c1bb8f
2 changed files with 6 additions and 3 deletions

View File

@ -3,6 +3,7 @@
import os import os
import invokeai.backend.util.logging as logger import invokeai.backend.util.logging as logger
from typing import types
from ..services.default_graphs import create_system_graphs from ..services.default_graphs import create_system_graphs
from ..services.latent_storage import DiskLatentsStorage, ForwardCacheLatentsStorage from ..services.latent_storage import DiskLatentsStorage, ForwardCacheLatentsStorage
@ -42,13 +43,15 @@ class ApiDependencies:
invoker: Invoker = None invoker: Invoker = None
@staticmethod @staticmethod
def initialize(config, event_handler_id: int): def initialize(config, event_handler_id: int, logger: types.ModuleType=logger):
Globals.try_patchmatch = config.patchmatch Globals.try_patchmatch = config.patchmatch
Globals.always_use_cpu = config.always_use_cpu Globals.always_use_cpu = config.always_use_cpu
Globals.internet_available = config.internet_available and check_internet() Globals.internet_available = config.internet_available and check_internet()
Globals.disable_xformers = not config.xformers Globals.disable_xformers = not config.xformers
Globals.ckpt_convert = config.ckpt_convert Globals.ckpt_convert = config.ckpt_convert
# TO DO: Use the config to select the logger rather than use the default
# invokeai logging module
logger.info(f"Internet connectivity is {Globals.internet_available}") logger.info(f"Internet connectivity is {Globals.internet_available}")
events = FastAPIEventService(event_handler_id) events = FastAPIEventService(event_handler_id)

View File

@ -3,6 +3,7 @@ import asyncio
from inspect import signature from inspect import signature
import uvicorn import uvicorn
import invokeai.backend.util.logging as logger
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
@ -16,7 +17,6 @@ from ..backend import Args
from .api.dependencies import ApiDependencies from .api.dependencies import ApiDependencies
from .api.routers import images, sessions, models from .api.routers import images, sessions, models
from .api.sockets import SocketIO from .api.sockets import SocketIO
from .invocations import *
from .invocations.baseinvocation import BaseInvocation from .invocations.baseinvocation import BaseInvocation
# Create the app # Create the app
@ -56,7 +56,7 @@ async def startup_event():
config.parse_args() config.parse_args()
ApiDependencies.initialize( ApiDependencies.initialize(
config=config, event_handler_id=event_handler_id config=config, event_handler_id=event_handler_id, logger=logger
) )