mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Run Ruff
This commit is contained in:
parent
9d0952c2ef
commit
39f62ac63c
@ -132,7 +132,7 @@ class ModelProbe(object):
|
|||||||
|
|
||||||
format_type = ModelFormat.Diffusers if model_path.is_dir() else ModelFormat.Checkpoint
|
format_type = ModelFormat.Diffusers if model_path.is_dir() else ModelFormat.Checkpoint
|
||||||
model_info = None
|
model_info = None
|
||||||
model_type = fields['type'] if 'type' in fields else None
|
model_type = fields["type"] if "type" in fields else None
|
||||||
model_type = ModelType(model_type) if isinstance(model_type, str) else model_type
|
model_type = ModelType(model_type) if isinstance(model_type, str) else model_type
|
||||||
if not model_type:
|
if not model_type:
|
||||||
if format_type is ModelFormat.Diffusers:
|
if format_type is ModelFormat.Diffusers:
|
||||||
|
@ -5,11 +5,12 @@ Test the model installer
|
|||||||
import platform
|
import platform
|
||||||
import uuid
|
import uuid
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from time import sleep
|
||||||
|
from typing import Any, Dict
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pydantic import ValidationError
|
from pydantic import ValidationError
|
||||||
from pydantic.networks import Url
|
from pydantic.networks import Url
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
from invokeai.app.services.config import InvokeAIAppConfig
|
from invokeai.app.services.config import InvokeAIAppConfig
|
||||||
from invokeai.app.services.events.events_base import EventServiceBase
|
from invokeai.app.services.events.events_base import EventServiceBase
|
||||||
@ -21,7 +22,7 @@ from invokeai.app.services.model_install import (
|
|||||||
URLModelSource,
|
URLModelSource,
|
||||||
)
|
)
|
||||||
from invokeai.app.services.model_records import UnknownModelException
|
from invokeai.app.services.model_records import UnknownModelException
|
||||||
from invokeai.backend.model_manager.config import BaseModelType, ModelFormat, ModelType, InvalidModelConfigException
|
from invokeai.backend.model_manager.config import BaseModelType, InvalidModelConfigException, ModelFormat, ModelType
|
||||||
from tests.backend.model_manager.model_manager_fixtures import * # noqa F403
|
from tests.backend.model_manager.model_manager_fixtures import * # noqa F403
|
||||||
|
|
||||||
OS = platform.uname().system
|
OS = platform.uname().system
|
||||||
@ -273,13 +274,13 @@ def test_404_download(mm2_installer: ModelInstallServiceBase, mm2_app_config: In
|
|||||||
{
|
{
|
||||||
"repo_id": "InvokeAI-test/textual_inversion_tests::learned_embeds-steps-1000.safetensors",
|
"repo_id": "InvokeAI-test/textual_inversion_tests::learned_embeds-steps-1000.safetensors",
|
||||||
"name": "test_lora",
|
"name": "test_lora",
|
||||||
"type": 'embedding',
|
"type": "embedding",
|
||||||
},
|
},
|
||||||
# SDXL, Lora - incorrect type
|
# SDXL, Lora - incorrect type
|
||||||
{
|
{
|
||||||
"repo_id": "InvokeAI-test/textual_inversion_tests::learned_embeds-steps-1000.safetensors",
|
"repo_id": "InvokeAI-test/textual_inversion_tests::learned_embeds-steps-1000.safetensors",
|
||||||
"name": "test_lora",
|
"name": "test_lora",
|
||||||
"type": 'lora',
|
"type": "lora",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -289,11 +290,11 @@ def test_heuristic_import_with_type(mm2_installer: ModelInstallServiceBase, mode
|
|||||||
"type": model_params["type"],
|
"type": model_params["type"],
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
assert("repo_id" in model_params)
|
assert "repo_id" in model_params
|
||||||
install_job = mm2_installer.heuristic_import(source=model_params["repo_id"], config=config)
|
install_job = mm2_installer.heuristic_import(source=model_params["repo_id"], config=config)
|
||||||
|
|
||||||
while not install_job.in_terminal_state:
|
while not install_job.in_terminal_state:
|
||||||
sleep(.01)
|
sleep(0.01)
|
||||||
assert(install_job.config_out if model_params["type"] == "embedding" else not install_job.config_out)
|
assert install_job.config_out if model_params["type"] == "embedding" else not install_job.config_out
|
||||||
except InvalidModelConfigException:
|
except InvalidModelConfigException:
|
||||||
assert model_params["type"] != "embedding"
|
assert model_params["type"] != "embedding"
|
||||||
|
@ -33,12 +33,12 @@ from invokeai.backend.model_manager.config import (
|
|||||||
from invokeai.backend.model_manager.load import ModelCache, ModelConvertCache
|
from invokeai.backend.model_manager.load import ModelCache, ModelConvertCache
|
||||||
from invokeai.backend.util.logging import InvokeAILogger
|
from invokeai.backend.util.logging import InvokeAILogger
|
||||||
from tests.backend.model_manager.model_metadata.metadata_examples import (
|
from tests.backend.model_manager.model_metadata.metadata_examples import (
|
||||||
|
HFTestLoraMetadata,
|
||||||
RepoCivitaiModelMetadata1,
|
RepoCivitaiModelMetadata1,
|
||||||
RepoCivitaiVersionMetadata1,
|
RepoCivitaiVersionMetadata1,
|
||||||
RepoHFMetadata1,
|
RepoHFMetadata1,
|
||||||
RepoHFMetadata1_nofp16,
|
RepoHFMetadata1_nofp16,
|
||||||
RepoHFModelJson1,
|
RepoHFModelJson1,
|
||||||
HFTestLoraMetadata,
|
|
||||||
)
|
)
|
||||||
from tests.fixtures.sqlite_database import create_mock_sqlite_database
|
from tests.fixtures.sqlite_database import create_mock_sqlite_database
|
||||||
|
|
||||||
@ -301,7 +301,7 @@ def mm2_session(embedding_file: Path, diffusers_dir: Path) -> Session:
|
|||||||
headers={"Content-Type": "application/json; charset=utf-8", "Content-Length": len(RepoHFMetadata1)},
|
headers={"Content-Type": "application/json; charset=utf-8", "Content-Length": len(RepoHFMetadata1)},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
with open(embedding_file, "rb") as f:
|
with open(embedding_file, "rb") as f:
|
||||||
data = f.read() # file is small - just 15K
|
data = f.read() # file is small - just 15K
|
||||||
sess.mount(
|
sess.mount(
|
||||||
|
Loading…
Reference in New Issue
Block a user