mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Configure script should not overwrite models.yaml if it is well formed (#4019)
## What type of PR is this? (check all applicable) - [ ] Refactor - [ ] Feature - [ X] Bug Fix - [ ] Optimization - [ ] Documentation Update - [ ] Community Node Submission ## Have you discussed this change with the InvokeAI team? - [ X] Yes - [ ] No, because: ## Have you updated all relevant documentation? - [ ] Yes - [ X] Not necessary ## Description When adding new core models to a 3.0.0 root directory needed to support SDXL, the configure script was (under some conditions) overwriting models.yaml. This PR corrects the problem.
This commit is contained in:
commit
f7f20fdfe4
@ -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
|
||||||
@ -57,7 +57,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,
|
||||||
)
|
)
|
||||||
@ -584,7 +583,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…
Reference in New Issue
Block a user