mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Resolving merge conflicts for flake8
This commit is contained in:
committed by
psychedelicious
parent
f6db9da06c
commit
537ae2f901
@ -1,13 +1,16 @@
|
||||
import os
|
||||
import pytest
|
||||
import sys
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from omegaconf import OmegaConf
|
||||
from pathlib import Path
|
||||
|
||||
os.environ["INVOKEAI_ROOT"] = "/tmp"
|
||||
|
||||
from invokeai.app.services.config import InvokeAIAppConfig
|
||||
@pytest.fixture
|
||||
def patch_rootdir(tmp_path: Path, monkeypatch: Any) -> None:
|
||||
"""This may be overkill since the current tests don't need the root dir to exist"""
|
||||
monkeypatch.setenv("INVOKEAI_ROOT", str(tmp_path))
|
||||
|
||||
|
||||
init1 = OmegaConf.create(
|
||||
"""
|
||||
@ -32,10 +35,12 @@ InvokeAI:
|
||||
)
|
||||
|
||||
|
||||
def test_use_init():
|
||||
def test_use_init(patch_rootdir):
|
||||
# note that we explicitly set omegaconf dict and argv here
|
||||
# so that the values aren't read from ~invokeai/invokeai.yaml and
|
||||
# sys.argv respectively.
|
||||
from invokeai.app.services.config import InvokeAIAppConfig
|
||||
|
||||
conf1 = InvokeAIAppConfig.get_config()
|
||||
assert conf1
|
||||
conf1.parse_args(conf=init1, argv=[])
|
||||
@ -51,7 +56,9 @@ def test_use_init():
|
||||
assert not hasattr(conf2, "invalid_attribute")
|
||||
|
||||
|
||||
def test_argv_override():
|
||||
def test_argv_override(patch_rootdir):
|
||||
from invokeai.app.services.config import InvokeAIAppConfig
|
||||
|
||||
conf = InvokeAIAppConfig.get_config()
|
||||
conf.parse_args(conf=init1, argv=["--always_use_cpu", "--max_cache=10"])
|
||||
assert conf.always_use_cpu
|
||||
@ -59,14 +66,16 @@ def test_argv_override():
|
||||
assert conf.outdir == Path("outputs") # this is the default
|
||||
|
||||
|
||||
def test_env_override():
|
||||
def test_env_override(patch_rootdir):
|
||||
from invokeai.app.services.config import InvokeAIAppConfig
|
||||
|
||||
# argv overrides
|
||||
conf = InvokeAIAppConfig()
|
||||
conf.parse_args(conf=init1, argv=["--max_cache=10"])
|
||||
assert conf.always_use_cpu == False
|
||||
assert conf.always_use_cpu is False
|
||||
os.environ["INVOKEAI_always_use_cpu"] = "True"
|
||||
conf.parse_args(conf=init1, argv=["--max_cache=10"])
|
||||
assert conf.always_use_cpu == True
|
||||
assert conf.always_use_cpu is True
|
||||
|
||||
# environment variables should be case insensitive
|
||||
os.environ["InvokeAI_Max_Cache_Size"] = "15"
|
||||
@ -76,7 +85,7 @@ def test_env_override():
|
||||
|
||||
conf = InvokeAIAppConfig()
|
||||
conf.parse_args(conf=init1, argv=["--no-always_use_cpu", "--max_cache=10"])
|
||||
assert conf.always_use_cpu == False
|
||||
assert conf.always_use_cpu is False
|
||||
assert conf.max_cache_size == 10
|
||||
|
||||
conf = InvokeAIAppConfig.get_config(max_cache_size=20)
|
||||
@ -84,7 +93,9 @@ def test_env_override():
|
||||
assert conf.max_cache_size == 20
|
||||
|
||||
|
||||
def test_root_resists_cwd():
|
||||
def test_root_resists_cwd(patch_rootdir):
|
||||
from invokeai.app.services.config import InvokeAIAppConfig
|
||||
|
||||
previous = os.environ["INVOKEAI_ROOT"]
|
||||
cwd = Path(os.getcwd()).resolve()
|
||||
|
||||
@ -99,7 +110,9 @@ def test_root_resists_cwd():
|
||||
os.chdir(cwd)
|
||||
|
||||
|
||||
def test_type_coercion():
|
||||
def test_type_coercion(patch_rootdir):
|
||||
from invokeai.app.services.config import InvokeAIAppConfig
|
||||
|
||||
conf = InvokeAIAppConfig().get_config()
|
||||
conf.parse_args(argv=["--root=/tmp/foobar"])
|
||||
assert conf.root == Path("/tmp/foobar")
|
||||
|
Reference in New Issue
Block a user