mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
groundwork for the bulk_download_service
This commit is contained in:
parent
f81388508f
commit
aba9cd3f9a
0
invokeai/app/services/bulk_download/__init__.py
Normal file
0
invokeai/app/services/bulk_download/__init__.py
Normal file
32
invokeai/app/services/bulk_download/bulk_download_base.py
Normal file
32
invokeai/app/services/bulk_download/bulk_download_base.py
Normal 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.
|
||||
"""
|
21
invokeai/app/services/bulk_download/bulk_download_common.py
Normal file
21
invokeai/app/services/bulk_download/bulk_download_common.py
Normal 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
|
Loading…
Reference in New Issue
Block a user