groundwork for the bulk_download_service

This commit is contained in:
Stefan Tobler 2024-01-07 19:54:58 -05:00 committed by Brandon Rising
parent f81388508f
commit aba9cd3f9a
3 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,32 @@
from pathlib import Path
from typing import Optional, Union
from abc import ABC, abstractmethod
from invokeai.app.services.events.events_base import EventServiceBase
from invokeai.app.services.invoker import Invoker
class BulkDownloadBase(ABC):
@abstractmethod
def __init__(
self,
output_folder: Union[str, Path],
event_bus: Optional["EventServiceBase"] = None,
):
"""
Create BulkDownloadBase object.
:param output_folder: The path to the output folder where the bulk download files can be temporarily stored.
:param event_bus: InvokeAI event bus for reporting events to.
"""
@abstractmethod
def start(self, invoker: Invoker, image_names: list[str], board_id: Optional[str]) -> str:
"""
Starts a a bulk download job.
:param invoker: The Invoker that holds all the services, required to be passed as a parameter to avoid circular dependencies.
:param image_names: A list of image names to include in the zip file.
:param board_id: The ID of the board. If provided, all images associated with the board will be included in the zip file.
"""

View File

@ -0,0 +1,21 @@
class BulkDownloadException(Exception):
"""Exception raised when a bulk download fails."""
def __init__(self, message="Bulk download failed"):
super().__init__(message)
self.message = message
class BulkDownloadTargetException(BulkDownloadException):
"""Exception raised when a bulk download target is not found."""
def __init__(self, message="The bulk download target was not found"):
super().__init__(message)
self.message = message
class BulkDownloadParametersException(BulkDownloadException):
"""Exception raised when a bulk download parameter is invalid."""
def __init__(self, message="The bulk download parameters are invalid, either an array of image names or a board id must be provided"):
super().__init__(message)
self.message = message