mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fbede84405
* add base definition of download manager * basic functionality working * add unit tests for download queue * add documentation and FastAPI route * fix docs * add missing test dependency; fix import ordering * fix file path length checking on windows * fix ruff check error * move release() into the __del__ method * disable testing of stderr messages due to issues with pytest capsys fixture * fix unsorted imports * harmonized implementation of start() and stop() calls in download and & install modules * Update invokeai/app/services/download/download_base.py Co-authored-by: Ryan Dick <ryanjdick3@gmail.com> * replace test datadir fixture with tmp_path * replace DownloadJobBase->DownloadJob in download manager documentation * make source and dest arguments to download_queue.download() an AnyHttpURL and Path respectively * fix pydantic typecheck errors in the download unit test * ruff formatting * add "job cancelled" as an event rather than an exception * fix ruff errors * Update invokeai/app/services/download/download_default.py Co-authored-by: psychedelicious <4822129+psychedelicious@users.noreply.github.com> * use threading.Event to stop service worker threads; handle unfinished job edge cases * remove dangling STOP job definition * fix ruff complaint * fix ruff check again * avoid race condition when start() and stop() are called simultaneously from different threads * avoid race condition in stop() when a job becomes active while shutting down --------- Co-authored-by: Lincoln Stein <lstein@gmail.com> Co-authored-by: Ryan Dick <ryanjdick3@gmail.com> Co-authored-by: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Co-authored-by: Kent Keirsey <31807370+hipsterusername@users.noreply.github.com>
119 lines
5.1 KiB
Python
119 lines
5.1 KiB
Python
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654) and the InvokeAI Team
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from logging import Logger
|
|
|
|
from .board_image_records.board_image_records_base import BoardImageRecordStorageBase
|
|
from .board_images.board_images_base import BoardImagesServiceABC
|
|
from .board_records.board_records_base import BoardRecordStorageBase
|
|
from .boards.boards_base import BoardServiceABC
|
|
from .config import InvokeAIAppConfig
|
|
from .download import DownloadQueueServiceBase
|
|
from .events.events_base import EventServiceBase
|
|
from .image_files.image_files_base import ImageFileStorageBase
|
|
from .image_records.image_records_base import ImageRecordStorageBase
|
|
from .images.images_base import ImageServiceABC
|
|
from .invocation_cache.invocation_cache_base import InvocationCacheBase
|
|
from .invocation_processor.invocation_processor_base import InvocationProcessorABC
|
|
from .invocation_queue.invocation_queue_base import InvocationQueueABC
|
|
from .invocation_stats.invocation_stats_base import InvocationStatsServiceBase
|
|
from .item_storage.item_storage_base import ItemStorageABC
|
|
from .latents_storage.latents_storage_base import LatentsStorageBase
|
|
from .model_install import ModelInstallServiceBase
|
|
from .model_manager.model_manager_base import ModelManagerServiceBase
|
|
from .model_records import ModelRecordServiceBase
|
|
from .names.names_base import NameServiceBase
|
|
from .session_processor.session_processor_base import SessionProcessorBase
|
|
from .session_queue.session_queue_base import SessionQueueBase
|
|
from .shared.graph import GraphExecutionState
|
|
from .urls.urls_base import UrlServiceBase
|
|
from .workflow_records.workflow_records_base import WorkflowRecordsStorageBase
|
|
|
|
|
|
class InvocationServices:
|
|
"""Services that can be used by invocations"""
|
|
|
|
# TODO: Just forward-declared everything due to circular dependencies. Fix structure.
|
|
board_images: "BoardImagesServiceABC"
|
|
board_image_record_storage: "BoardImageRecordStorageBase"
|
|
boards: "BoardServiceABC"
|
|
board_records: "BoardRecordStorageBase"
|
|
configuration: "InvokeAIAppConfig"
|
|
events: "EventServiceBase"
|
|
graph_execution_manager: "ItemStorageABC[GraphExecutionState]"
|
|
images: "ImageServiceABC"
|
|
image_records: "ImageRecordStorageBase"
|
|
image_files: "ImageFileStorageBase"
|
|
latents: "LatentsStorageBase"
|
|
logger: "Logger"
|
|
model_manager: "ModelManagerServiceBase"
|
|
model_records: "ModelRecordServiceBase"
|
|
download_queue: "DownloadQueueServiceBase"
|
|
model_install: "ModelInstallServiceBase"
|
|
processor: "InvocationProcessorABC"
|
|
performance_statistics: "InvocationStatsServiceBase"
|
|
queue: "InvocationQueueABC"
|
|
session_queue: "SessionQueueBase"
|
|
session_processor: "SessionProcessorBase"
|
|
invocation_cache: "InvocationCacheBase"
|
|
names: "NameServiceBase"
|
|
urls: "UrlServiceBase"
|
|
workflow_records: "WorkflowRecordsStorageBase"
|
|
|
|
def __init__(
|
|
self,
|
|
board_images: "BoardImagesServiceABC",
|
|
board_image_records: "BoardImageRecordStorageBase",
|
|
boards: "BoardServiceABC",
|
|
board_records: "BoardRecordStorageBase",
|
|
configuration: "InvokeAIAppConfig",
|
|
events: "EventServiceBase",
|
|
graph_execution_manager: "ItemStorageABC[GraphExecutionState]",
|
|
images: "ImageServiceABC",
|
|
image_files: "ImageFileStorageBase",
|
|
image_records: "ImageRecordStorageBase",
|
|
latents: "LatentsStorageBase",
|
|
logger: "Logger",
|
|
model_manager: "ModelManagerServiceBase",
|
|
model_records: "ModelRecordServiceBase",
|
|
download_queue: "DownloadQueueServiceBase",
|
|
model_install: "ModelInstallServiceBase",
|
|
processor: "InvocationProcessorABC",
|
|
performance_statistics: "InvocationStatsServiceBase",
|
|
queue: "InvocationQueueABC",
|
|
session_queue: "SessionQueueBase",
|
|
session_processor: "SessionProcessorBase",
|
|
invocation_cache: "InvocationCacheBase",
|
|
names: "NameServiceBase",
|
|
urls: "UrlServiceBase",
|
|
workflow_records: "WorkflowRecordsStorageBase",
|
|
):
|
|
self.board_images = board_images
|
|
self.board_image_records = board_image_records
|
|
self.boards = boards
|
|
self.board_records = board_records
|
|
self.configuration = configuration
|
|
self.events = events
|
|
self.graph_execution_manager = graph_execution_manager
|
|
self.images = images
|
|
self.image_files = image_files
|
|
self.image_records = image_records
|
|
self.latents = latents
|
|
self.logger = logger
|
|
self.model_manager = model_manager
|
|
self.model_records = model_records
|
|
self.download_queue = download_queue
|
|
self.model_install = model_install
|
|
self.processor = processor
|
|
self.performance_statistics = performance_statistics
|
|
self.queue = queue
|
|
self.session_queue = session_queue
|
|
self.session_processor = session_processor
|
|
self.invocation_cache = invocation_cache
|
|
self.names = names
|
|
self.urls = urls
|
|
self.workflow_records = workflow_records
|