mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
if models.yaml doesn't exist, rebuild it
This commit is contained in:
parent
f4aa28bee0
commit
5f7435955e
@ -258,8 +258,6 @@ class ModelManagerService(ModelManagerServiceBase):
|
|||||||
config_file = config.model_conf_path
|
config_file = config.model_conf_path
|
||||||
else:
|
else:
|
||||||
config_file = config.root_dir / "configs/models.yaml"
|
config_file = config.root_dir / "configs/models.yaml"
|
||||||
if not config_file.exists():
|
|
||||||
raise IOError(f"The file {config_file} could not be found.")
|
|
||||||
|
|
||||||
logger.debug(f'config file={config_file}')
|
logger.debug(f'config file={config_file}')
|
||||||
|
|
||||||
|
@ -231,6 +231,7 @@ from __future__ import annotations
|
|||||||
import os
|
import os
|
||||||
import hashlib
|
import hashlib
|
||||||
import textwrap
|
import textwrap
|
||||||
|
import yaml
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, List, Tuple, Union, Dict, Set, Callable, types
|
from typing import Optional, List, Tuple, Union, Dict, Set, Callable, types
|
||||||
@ -314,6 +315,9 @@ class ModelManager(object):
|
|||||||
self.config_path = None
|
self.config_path = None
|
||||||
if isinstance(config, (str, Path)):
|
if isinstance(config, (str, Path)):
|
||||||
self.config_path = Path(config)
|
self.config_path = Path(config)
|
||||||
|
if not self.config_path.exists():
|
||||||
|
logger.warning(f'The file {self.config_path} was not found. Initializing a new file')
|
||||||
|
self.initialize_model_config(self.config_path)
|
||||||
config = OmegaConf.load(self.config_path)
|
config = OmegaConf.load(self.config_path)
|
||||||
|
|
||||||
elif not isinstance(config, DictConfig):
|
elif not isinstance(config, DictConfig):
|
||||||
@ -386,6 +390,16 @@ class ModelManager(object):
|
|||||||
def _get_model_cache_path(self, model_path):
|
def _get_model_cache_path(self, model_path):
|
||||||
return self.app_config.models_path / ".cache" / hashlib.md5(str(model_path).encode()).hexdigest()
|
return self.app_config.models_path / ".cache" / hashlib.md5(str(model_path).encode()).hexdigest()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def initialize_model_config(cls, config_path: Path):
|
||||||
|
"""Create empty config file"""
|
||||||
|
with open(config_path,'w') as yaml_file:
|
||||||
|
yaml_file.write(yaml.dump({'__metadata__':
|
||||||
|
{'version':'3.0.0'}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def get_model(
|
def get_model(
|
||||||
self,
|
self,
|
||||||
model_name: str,
|
model_name: str,
|
||||||
|
Loading…
Reference in New Issue
Block a user