fix flake8 errors

This commit is contained in:
Lincoln Stein
2023-08-20 16:38:41 -04:00
parent 0deb3f9e2a
commit 1784aeb343
6 changed files with 16 additions and 21 deletions

View File

@ -1,7 +1,7 @@
"""
Initialization file for invokeai.backend.model_manager.config
"""
from invokeai.backend.model_manager.config import (
from invokeai.backend.model_manager.config import ( # noqa F401
ModelConfigFactory,
ModelConfigBase,
InvalidModelConfigException,
@ -12,4 +12,3 @@ from invokeai.backend.model_manager.config import (
ModelFormat,
SchedulerPredictionType,
)

View File

@ -19,20 +19,16 @@ Typical usage:
Validation errors will raise an InvalidModelConfigException error.
"""
import pydantic
from enum import Enum
from pydantic import BaseModel, Field, Extra
from typing import Optional, Literal, List, Union, Type
from pydantic.error_wrappers import ValidationError
from omegaconf.listconfig import ListConfig # to support the yaml backend
import pydantic
from pydantic import BaseModel, Field, Extra
from pydantic.error_wrappers import ValidationError
class InvalidModelConfigException(Exception):
"""Exception raised when the config parser doesn't recognize the passed
combination of model type and format."""
pass
"""Exception for when config parser doesn't recognized this combination of model type and format."""
class BaseModelType(str, Enum):
"""Base model type."""
@ -201,7 +197,7 @@ class ONNXSD2Config(MainConfig):
class ModelConfigFactory(object):
"""Class for parsing config dicts into StableDiffusion*Config obects."""
"""Class for parsing config dicts into StableDiffusion Config obects."""
_class_map: dict = {
ModelFormat.Checkpoint: {

View File

@ -1,6 +1,6 @@
"""
Initialization file for invokeai.backend.model_manager.storage
"""
from .base import ModelConfigStore, UnknownModelException
from .yaml import ModelConfigStoreYAML
from .sql import ModelConfigStoreSQL
from .base import ModelConfigStore, UnknownModelException # noqa F401
from .yaml import ModelConfigStoreYAML # noqa F401
from .sql import ModelConfigStoreSQL # noqa F401

View File

@ -13,14 +13,10 @@ from ..config import ModelConfigBase, BaseModelType, ModelType
class DuplicateModelException(Exception):
"""Raised on an attempt to add a model with the same key twice."""
pass
class UnknownModelException(Exception):
"""Raised on an attempt to delete a model with a nonexistent key."""
pass
class ModelConfigStore(ABC):
"""Abstract base class for storage and retrieval of model configs."""

View File

@ -294,7 +294,7 @@ class ModelConfigStoreSQL(ModelConfigStore):
required fields, or a ModelConfigBase instance.
"""
record = ModelConfigFactory.make_config(config) # ensure it is a valid config obect
json_serialized = json.dumps(record.dict()) # and turn it into a json string.
json_serialized = json.dumps(record.dict()) # and turn it into a json string.
try:
self._lock.acquire()
self._cursor.execute(
@ -307,7 +307,11 @@ class ModelConfigStoreSQL(ModelConfigStore):
config=?
WHERE id=?;
""",
(record.base_model, record.model_type, record.name, record.path, json_serialized, key),
(record.base_model,
record.model_type,
record.name,
record.path,
json_serialized, key),
)
if self._cursor.rowcount < 1:
raise UnknownModelException

View File

@ -192,7 +192,7 @@ class ModelConfigStoreYAML(ModelConfigStore):
self._lock.acquire()
for config in self.all_models():
config_tags = set(config.tags)
if tags.difference(config_tags): # not all tags in the model
if tags.difference(config_tags): # not all tags in the model
continue
results.append(config)
finally: