Skip to content

Commit 4121c26

Browse files
author
Lincoln Stein
committed
fix missing models when INVOKEAI_ROOT="."
1 parent 99823d5 commit 4121c26

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

invokeai/app/services/config.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ class InvokeBatch(InvokeAISettings):
174174
DB_FILE = Path("invokeai.db")
175175
LEGACY_INIT_FILE = Path("invokeai.init")
176176

177-
178177
class InvokeAISettings(BaseSettings):
179178
"""
180179
Runtime configuration settings in which default values are
@@ -274,7 +273,7 @@ def add_subparser(cls, parser: argparse.ArgumentParser):
274273
@classmethod
275274
def _excluded(self) -> List[str]:
276275
# internal fields that shouldn't be exposed as command line options
277-
return ["type", "initconf"]
276+
return ["type", "initconf","cached_root"]
278277

279278
@classmethod
280279
def _excluded_from_yaml(self) -> List[str]:
@@ -290,6 +289,7 @@ def _excluded_from_yaml(self) -> List[str]:
290289
"restore",
291290
"root",
292291
"nsfw_checker",
292+
"cached_root",
293293
]
294294

295295
class Config:
@@ -362,7 +362,6 @@ def _find_root() -> Path:
362362
root = Path("~/invokeai").expanduser().resolve()
363363
return root
364364

365-
366365
class InvokeAIAppConfig(InvokeAISettings):
367366
"""
368367
Generate images using Stable Diffusion. Use "invokeai" to launch
@@ -423,6 +422,7 @@ class InvokeAIAppConfig(InvokeAISettings):
423422
log_level : Literal[tuple(["debug","info","warning","error","critical"])] = Field(default="info", description="Emit logging messages at this level or higher", category="Logging")
424423

425424
version : bool = Field(default=False, description="Show InvokeAI version and exit", category="Other")
425+
cached_root : Path = Field(default=None, description="internal use only", category="DEPRECATED")
426426
# fmt: on
427427

428428
def parse_args(self, argv: List[str] = None, conf: DictConfig = None, clobber=False):
@@ -470,10 +470,15 @@ def root_path(self) -> Path:
470470
"""
471471
Path to the runtime root directory
472472
"""
473-
if self.root:
474-
return Path(self.root).expanduser().absolute()
473+
# we cache value of root to protect against it being '.' and the cwd changing
474+
if self.cached_root:
475+
root = self.cached_root
476+
elif self.root:
477+
root = Path(self.root).expanduser().absolute()
475478
else:
476-
return self.find_root()
479+
root = self.find_root()
480+
self.cached_root = root
481+
return self.cached_root
477482

478483
@property
479484
def root_dir(self) -> Path:

0 commit comments

Comments
 (0)