partially address --root CLI argument handling

- fix places where `get_config()` is being called at import time rather
  than at run time.

- add regression test for import time get_config() calling.
This commit is contained in:
Lincoln Stein
2024-03-16 22:25:19 -04:00
committed by psychedelicious
parent 8cd65755ef
commit d871fca643
5 changed files with 24 additions and 11 deletions

View File

@ -1,3 +1,4 @@
import sys
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Any
@ -7,6 +8,7 @@ from omegaconf import OmegaConf
from pydantic import ValidationError
from invokeai.app.services.config.config_default import InvokeAIAppConfig, get_config, load_and_migrate_config
from invokeai.frontend.cli.arg_parser import InvokeAIArgs
v4_config = """
schema_version: 4
@ -76,6 +78,13 @@ def test_read_config_from_file(tmp_path: Path):
assert config.port == 8080
def test_arg_parsing():
sys.argv = ["test_config.py", "--root", "/tmp"]
InvokeAIArgs.parse_args()
config = get_config()
assert config.root_path == Path("/tmp")
def test_migrate_v3_config_from_file(tmp_path: Path):
"""Test reading configuration from a file."""
temp_config_file = tmp_path / "temp_invokeai.yaml"