mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(config): split check_invokeai_root into separate function to validate, use this in model_install to determine if need to run configurator
This commit is contained in:
parent
9539ecce79
commit
b8c46fb15b
@ -7,10 +7,14 @@ import sys
|
|||||||
from invokeai.app.services.config import InvokeAIAppConfig
|
from invokeai.app.services.config import InvokeAIAppConfig
|
||||||
|
|
||||||
|
|
||||||
|
def validate_root_structure(config: InvokeAIAppConfig) -> None:
|
||||||
|
assert config.db_path.parent.exists(), f"{config.db_path.parent} not found"
|
||||||
|
assert config.models_path.exists(), f"{config.models_path} not found"
|
||||||
|
|
||||||
|
|
||||||
def check_invokeai_root(config: InvokeAIAppConfig):
|
def check_invokeai_root(config: InvokeAIAppConfig):
|
||||||
try:
|
try:
|
||||||
assert config.db_path.parent.exists(), f"{config.db_path.parent} not found"
|
validate_root_structure(config)
|
||||||
assert config.models_path.exists(), f"{config.models_path} not found"
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print()
|
print()
|
||||||
print(f"An exception has occurred: {str(e)}")
|
print(f"An exception has occurred: {str(e)}")
|
||||||
|
@ -22,8 +22,9 @@ import npyscreen
|
|||||||
import torch
|
import torch
|
||||||
from npyscreen import widget
|
from npyscreen import widget
|
||||||
|
|
||||||
from invokeai.app.services.config import InvokeAIAppConfig
|
from invokeai.app.services.config.config_default import get_config
|
||||||
from invokeai.app.services.model_install import ModelInstallServiceBase
|
from invokeai.app.services.model_install import ModelInstallServiceBase
|
||||||
|
from invokeai.backend.install.check_root import validate_root_structure
|
||||||
from invokeai.backend.install.install_helper import InstallHelper, InstallSelections, UnifiedModelInfo
|
from invokeai.backend.install.install_helper import InstallHelper, InstallSelections, UnifiedModelInfo
|
||||||
from invokeai.backend.model_manager import ModelType
|
from invokeai.backend.model_manager import ModelType
|
||||||
from invokeai.backend.util import choose_precision, choose_torch_device
|
from invokeai.backend.util import choose_precision, choose_torch_device
|
||||||
@ -41,8 +42,8 @@ from invokeai.frontend.install.widgets import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
warnings.filterwarnings("ignore", category=UserWarning) # noqa: E402
|
warnings.filterwarnings("ignore", category=UserWarning) # noqa: E402
|
||||||
config = InvokeAIAppConfig.get_config()
|
config = get_config()
|
||||||
logger = InvokeAILogger.get_logger("ModelInstallService")
|
logger = InvokeAILogger.get_logger("ModelInstallService", config=config)
|
||||||
# logger.setLevel("WARNING")
|
# logger.setLevel("WARNING")
|
||||||
# logger.setLevel('DEBUG')
|
# logger.setLevel('DEBUG')
|
||||||
|
|
||||||
@ -600,15 +601,17 @@ def main() -> None:
|
|||||||
)
|
)
|
||||||
opt = parser.parse_args()
|
opt = parser.parse_args()
|
||||||
|
|
||||||
invoke_args = []
|
invoke_args: dict[str, Any] = {}
|
||||||
if opt.root:
|
if opt.root:
|
||||||
invoke_args.extend(["--root", opt.root])
|
invoke_args["root"] = opt.root
|
||||||
if opt.full_precision:
|
if opt.full_precision:
|
||||||
invoke_args.extend(["--precision", "float32"])
|
invoke_args["precision"] = "float32"
|
||||||
config.parse_args(invoke_args)
|
config.update_config(invoke_args)
|
||||||
logger = InvokeAILogger().get_logger(config=config)
|
logger = InvokeAILogger().get_logger(config=config)
|
||||||
|
|
||||||
if not config.models_path.exists():
|
try:
|
||||||
|
validate_root_structure(config)
|
||||||
|
except AssertionError:
|
||||||
logger.info("Your InvokeAI root directory is not set up. Calling invokeai-configure.")
|
logger.info("Your InvokeAI root directory is not set up. Calling invokeai-configure.")
|
||||||
sys.argv = ["invokeai_configure", "--yes", "--skip-sd-weights"]
|
sys.argv = ["invokeai_configure", "--yes", "--skip-sd-weights"]
|
||||||
from invokeai.frontend.install.invokeai_configure import invokeai_configure
|
from invokeai.frontend.install.invokeai_configure import invokeai_configure
|
||||||
|
Loading…
Reference in New Issue
Block a user