mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
do not overwrite models.yaml if it is well formed
This commit is contained in:
parent
0d344872f1
commit
451b8c96e5
@ -13,8 +13,8 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import textwrap
|
import textwrap
|
||||||
import traceback
|
import traceback
|
||||||
import warnings
|
|
||||||
import yaml
|
import yaml
|
||||||
|
import warnings
|
||||||
from argparse import Namespace
|
from argparse import Namespace
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from shutil import get_terminal_size
|
from shutil import get_terminal_size
|
||||||
@ -56,7 +56,6 @@ from invokeai.frontend.install.widgets import (
|
|||||||
from invokeai.backend.install.legacy_arg_parsing import legacy_parser
|
from invokeai.backend.install.legacy_arg_parsing import legacy_parser
|
||||||
from invokeai.backend.install.model_install_backend import (
|
from invokeai.backend.install.model_install_backend import (
|
||||||
hf_download_from_pretrained,
|
hf_download_from_pretrained,
|
||||||
hf_download_with_resume,
|
|
||||||
InstallSelections,
|
InstallSelections,
|
||||||
ModelInstall,
|
ModelInstall,
|
||||||
)
|
)
|
||||||
@ -391,7 +390,7 @@ Use cursor arrows to make a checkbox selection, and space to toggle.
|
|||||||
self.autoimport_dirs = {}
|
self.autoimport_dirs = {}
|
||||||
self.autoimport_dirs['autoimport_dir'] = self.add_widget_intelligent(
|
self.autoimport_dirs['autoimport_dir'] = self.add_widget_intelligent(
|
||||||
FileBox,
|
FileBox,
|
||||||
name=f'Autoimport Folder',
|
name='Autoimport Folder',
|
||||||
value=str(config.root_path / config.autoimport_dir),
|
value=str(config.root_path / config.autoimport_dir),
|
||||||
select_dir=True,
|
select_dir=True,
|
||||||
must_exist=False,
|
must_exist=False,
|
||||||
@ -583,7 +582,18 @@ def initialize_rootdir(root: Path, yes_to_all: bool = False):
|
|||||||
path = dest / 'core'
|
path = dest / 'core'
|
||||||
path.mkdir(parents=True, exist_ok=True)
|
path.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
with open(root / 'configs' / 'models.yaml','w') as yaml_file:
|
maybe_create_models_yaml(root)
|
||||||
|
|
||||||
|
def maybe_create_models_yaml(root: Path):
|
||||||
|
models_yaml = root / 'configs' / 'models.yaml'
|
||||||
|
if models_yaml.exists():
|
||||||
|
if OmegaConf.load(models_yaml).get('__metadata__'): # up to date
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
logger.info('Creating new models.yaml, original saved as models.yaml.orig')
|
||||||
|
models_yaml.rename(models_yaml.parent / 'models.yaml.orig')
|
||||||
|
|
||||||
|
with open(models_yaml,'w') as yaml_file:
|
||||||
yaml_file.write(yaml.dump({'__metadata__':
|
yaml_file.write(yaml.dump({'__metadata__':
|
||||||
{'version':'3.0.0'}
|
{'version':'3.0.0'}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user