mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-01-14 22:38:02 -05:00
tidy(app): make workflow thumbnails base class an ABC, move it to own file
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import Image
|
||||
|
||||
|
||||
class WorkflowThumbnailServiceBase(ABC):
|
||||
"""Base class for workflow thumbnail services"""
|
||||
|
||||
@abstractmethod
|
||||
def get_path(self, workflow_id: str) -> Path:
|
||||
"""Gets the path to a workflow thumbnail"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_url(self, workflow_id: str) -> str | None:
|
||||
"""Gets the URL of a workflow thumbnail"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def save(self, workflow_id: str, image: Image.Image) -> None:
|
||||
"""Saves a workflow thumbnail"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def delete(self, workflow_id: str) -> None:
|
||||
"""Deletes a workflow thumbnail"""
|
||||
pass
|
||||
@@ -1,8 +1,3 @@
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import Image
|
||||
|
||||
|
||||
class WorkflowThumbnailFileNotFoundException(Exception):
|
||||
"""Raised when a workflow thumbnail file is not found"""
|
||||
|
||||
@@ -25,23 +20,3 @@ class WorkflowThumbnailFileDeleteException(Exception):
|
||||
def __init__(self, message: str = "Workflow thumbnail file cannot be deleted"):
|
||||
self.message = message
|
||||
super().__init__(self.message)
|
||||
|
||||
|
||||
class WorkflowThumbnailServiceBase:
|
||||
"""Base class for workflow thumbnail services"""
|
||||
|
||||
def get_path(self, workflow_id: str) -> Path:
|
||||
"""Gets the path to a workflow thumbnail"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_url(self, workflow_id: str) -> str | None:
|
||||
"""Gets the URL of a workflow thumbnail"""
|
||||
raise NotImplementedError
|
||||
|
||||
def save(self, workflow_id: str, image: Image.Image) -> None:
|
||||
"""Saves a workflow thumbnail"""
|
||||
raise NotImplementedError
|
||||
|
||||
def delete(self, workflow_id: str) -> None:
|
||||
"""Deletes a workflow thumbnail"""
|
||||
raise NotImplementedError
|
||||
|
||||
@@ -4,11 +4,11 @@ from PIL import Image
|
||||
from PIL.Image import Image as PILImageType
|
||||
|
||||
from invokeai.app.services.invoker import Invoker
|
||||
from invokeai.app.services.workflow_thumbnails.workflow_thumbnails_base import WorkflowThumbnailServiceBase
|
||||
from invokeai.app.services.workflow_thumbnails.workflow_thumbnails_common import (
|
||||
WorkflowThumbnailFileDeleteException,
|
||||
WorkflowThumbnailFileNotFoundException,
|
||||
WorkflowThumbnailFileSaveException,
|
||||
WorkflowThumbnailServiceBase,
|
||||
)
|
||||
from invokeai.app.util.misc import uuid_string
|
||||
from invokeai.app.util.thumbnails import make_thumbnail
|
||||
|
||||
Reference in New Issue
Block a user