docs(events): update event docstrings

This commit is contained in:
psychedelicious 2024-03-14 19:25:55 +11:00
parent cfa4e5f88e
commit 0abc328ddf
2 changed files with 50 additions and 25 deletions

View File

@ -56,6 +56,7 @@ class EventServiceBase:
# region: Invocation
def emit_invocation_started(self, queue_item: "SessionQueueItem", invocation: "BaseInvocation") -> None:
"""Emitted when an invocation is started"""
self.dispatch(InvocationStartedEvent.build(queue_item, invocation))
def emit_invocation_denoise_progress(
@ -66,16 +67,19 @@ class EventServiceBase:
total_steps: int,
progress_image: "ProgressImage",
) -> None:
"""Emitted at each step during denoising of an invocation."""
self.dispatch(InvocationDenoiseProgressEvent.build(queue_item, invocation, step, total_steps, progress_image))
def emit_invocation_complete(
self, queue_item: "SessionQueueItem", invocation: "BaseInvocation", output: "BaseInvocationOutput"
) -> None:
"""Emitted when an invocation is complete"""
self.dispatch(InvocationCompleteEvent.build(queue_item, invocation, output))
def emit_invocation_error(
self, queue_item: "SessionQueueItem", invocation: "BaseInvocation", error_type: str, error: str
) -> None:
"""Emitted when an invocation encounters an error"""
self.dispatch(InvocationErrorEvent.build(queue_item, invocation, error_type, error))
# endregion
@ -83,12 +87,15 @@ class EventServiceBase:
# region Session
def emit_session_started(self, queue_item: "SessionQueueItem") -> None:
"""Emitted when a session has started"""
self.dispatch(SessionStartedEvent.build(queue_item))
def emit_session_complete(self, queue_item: "SessionQueueItem") -> None:
"""Emitted when a session has completed all invocations"""
self.dispatch(SessionCompleteEvent.build(queue_item))
def emit_session_canceled(self, queue_item: "SessionQueueItem") -> None:
"""Emitted when a session is canceled"""
self.dispatch(SessionCanceledEvent.build(queue_item))
# endregion
@ -98,12 +105,15 @@ class EventServiceBase:
def emit_queue_item_status_changed(
self, queue_item: "SessionQueueItem", batch_status: "BatchStatus", queue_status: "SessionQueueStatus"
) -> None:
"""Emitted when a queue item's status changes"""
self.dispatch(QueueItemStatusChangedEvent.build(queue_item, batch_status, queue_status))
def emit_batch_enqueued(self, enqueue_result: "EnqueueBatchResult") -> None:
"""Emitted when a batch is enqueued"""
self.dispatch(BatchEnqueuedEvent.build(enqueue_result))
def emit_queue_cleared(self, queue_id: str) -> None:
"""Emitted when a queue is cleared"""
self.dispatch(QueueClearedEvent.build(queue_id))
# endregion
@ -111,18 +121,23 @@ class EventServiceBase:
# region Download
def emit_download_started(self, source: str, download_path: str) -> None:
"""Emitted when a download is started"""
self.dispatch(DownloadStartedEvent.build(source, download_path))
def emit_download_progress(self, source: str, download_path: str, current_bytes: int, total_bytes: int) -> None:
"""Emitted at intervals during a download"""
self.dispatch(DownloadProgressEvent.build(source, download_path, current_bytes, total_bytes))
def emit_download_complete(self, source: str, download_path: str, total_bytes: int) -> None:
"""Emitted when a download is completed"""
self.dispatch(DownloadCompleteEvent.build(source, download_path, total_bytes))
def emit_download_cancelled(self, source: str) -> None:
"""Emitted when a download is cancelled"""
self.dispatch(DownloadCancelledEvent.build(source))
def emit_download_error(self, source: str, error_type: str, error: str) -> None:
"""Emitted when a download encounters an error"""
self.dispatch(DownloadErrorEvent.build(source, error_type, error))
# endregion
@ -130,9 +145,11 @@ class EventServiceBase:
# region Model loading
def emit_model_load_started(self, config: "AnyModelConfig", submodel_type: Optional["SubModelType"] = None) -> None:
"""Emitted when a model load is started."""
self.dispatch(ModelLoadStartedEvent.build(config, submodel_type))
def emit_model_load_complete(self, config: "AnyModelConfig", submodel_type: Optional["SubModelType"] = None) -> None:
"""Emitted when a model load is complete."""
self.dispatch(ModelLoadCompleteEvent.build(config, submodel_type))
# endregion
@ -140,21 +157,26 @@ class EventServiceBase:
# region Model install
def emit_model_install_download_progress(self, job: "ModelInstallJob") -> None:
"""Emitted at intervals while the install job is in progress (remote models only)."""
self.dispatch(ModelInstallDownloadProgressEvent.build(job))
def emit_model_install_downloads_complete(self, job: "ModelInstallJob") -> None:
self.dispatch(ModelInstallDownloadsCompleteEvent.build(job))
def emit_model_install_started(self, job: "ModelInstallJob") -> None:
"""Emitted once when an install job is started (after any download)."""
self.dispatch(ModelInstallStartedEvent.build(job))
def emit_model_install_complete(self, job: "ModelInstallJob") -> None:
"""Emitted when an install job is completed successfully."""
self.dispatch(ModelInstallCompleteEvent.build(job))
def emit_model_install_cancelled(self, job: "ModelInstallJob") -> None:
"""Emitted when an install job is cancelled."""
self.dispatch(ModelInstallCancelledEvent.build(job))
def emit_model_install_error(self, job: "ModelInstallJob") -> None:
"""Emitted when an install job encounters an exception."""
self.dispatch(ModelInstallErrorEvent.build(job))
# endregion
@ -164,16 +186,19 @@ class EventServiceBase:
def emit_bulk_download_started(
self, bulk_download_id: str, bulk_download_item_id: str, bulk_download_item_name: str
) -> None:
"""Emitted when a bulk image download is started"""
self.dispatch(BulkDownloadStartedEvent.build(bulk_download_id, bulk_download_item_id, bulk_download_item_name))
def emit_bulk_download_complete(
self, bulk_download_id: str, bulk_download_item_id: str, bulk_download_item_name: str
) -> None:
"""Emitted when a bulk image download is complete"""
self.dispatch(BulkDownloadCompleteEvent.build(bulk_download_id, bulk_download_item_id, bulk_download_item_name))
def emit_bulk_download_error(
self, bulk_download_id: str, bulk_download_item_id: str, bulk_download_item_name: str, error: str
) -> None:
"""Emitted when a bulk image download has an error"""
self.dispatch(
BulkDownloadErrorEvent.build(bulk_download_id, bulk_download_item_id, bulk_download_item_name, error)
)

View File

@ -93,7 +93,7 @@ class InvocationEventBase(SessionEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class InvocationStartedEvent(InvocationEventBase):
"""Emitted when an invocation is started"""
"""Event model for invocation_started"""
__event_name__ = "invocation_started"
@ -112,7 +112,7 @@ class InvocationStartedEvent(InvocationEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class InvocationDenoiseProgressEvent(InvocationEventBase):
"""Emitted at each step during denoising of an invocation."""
"""Event model for invocation_denoise_progress"""
__event_name__ = "invocation_denoise_progress"
@ -145,7 +145,7 @@ class InvocationDenoiseProgressEvent(InvocationEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class InvocationCompleteEvent(InvocationEventBase):
"""Emitted when an invocation is complete"""
"""Event model for invocation_complete"""
__event_name__ = "invocation_complete"
@ -169,7 +169,7 @@ class InvocationCompleteEvent(InvocationEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class InvocationErrorEvent(InvocationEventBase):
"""Emitted when an invocation encounters an error"""
"""Event model for invocation_error"""
__event_name__ = "invocation_error"
@ -195,7 +195,7 @@ class InvocationErrorEvent(InvocationEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class SessionStartedEvent(SessionEventBase):
"""Emitted when a session has started"""
"""Event model for session_started"""
__event_name__ = "session_started"
@ -211,7 +211,7 @@ class SessionStartedEvent(SessionEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class SessionCompleteEvent(SessionEventBase):
"""Emitted when a session has completed all invocations"""
"""Event model for session_complete"""
__event_name__ = "session_complete"
@ -227,7 +227,7 @@ class SessionCompleteEvent(SessionEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class SessionCanceledEvent(SessionEventBase):
"""Emitted when a session is canceled"""
"""Event model for session_canceled"""
__event_name__ = "session_canceled"
@ -243,7 +243,7 @@ class SessionCanceledEvent(SessionEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class QueueItemStatusChangedEvent(QueueItemEventBase):
"""Emitted when a queue item's status changes"""
"""Event model for queue_item_status_changed"""
__event_name__ = "queue_item_status_changed"
@ -277,7 +277,7 @@ class QueueItemStatusChangedEvent(QueueItemEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class BatchEnqueuedEvent(QueueEventBase):
"""Emitted when a batch is enqueued"""
"""Event model for batch_enqueued"""
__event_name__ = "batch_enqueued"
@ -301,7 +301,7 @@ class BatchEnqueuedEvent(QueueEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class QueueClearedEvent(QueueEventBase):
"""Emitted when a queue is cleared"""
"""Event model for queue_cleared"""
__event_name__ = "queue_cleared"
@ -318,7 +318,7 @@ class DownloadEventBase(EventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class DownloadStartedEvent(DownloadEventBase):
"""Emitted when a download is started"""
"""Event model for download_started"""
__event_name__ = "download_started"
@ -331,7 +331,7 @@ class DownloadStartedEvent(DownloadEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class DownloadProgressEvent(DownloadEventBase):
"""Emitted at intervals during a download"""
"""Event model for download_progress"""
__event_name__ = "download_progress"
@ -346,7 +346,7 @@ class DownloadProgressEvent(DownloadEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class DownloadCompleteEvent(DownloadEventBase):
"""Emitted when a download is completed"""
"""Event model for download_complete"""
__event_name__ = "download_complete"
@ -360,7 +360,7 @@ class DownloadCompleteEvent(DownloadEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class DownloadCancelledEvent(DownloadEventBase):
"""Emitted when a download is cancelled"""
"""Event model for download_cancelled"""
__event_name__ = "download_cancelled"
@ -371,7 +371,7 @@ class DownloadCancelledEvent(DownloadEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class DownloadErrorEvent(DownloadEventBase):
"""Emitted when a download encounters an error"""
"""Event model for download_error"""
__event_name__ = "download_error"
@ -389,7 +389,7 @@ class ModelEventBase(EventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class ModelLoadStartedEvent(ModelEventBase):
"""Emitted when a model is requested"""
"""Event model for model_load_started"""
__event_name__ = "model_load_started"
@ -403,7 +403,7 @@ class ModelLoadStartedEvent(ModelEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class ModelLoadCompleteEvent(ModelEventBase):
"""Emitted when a model is requested"""
"""Event model for model_load_complete"""
__event_name__ = "model_load_complete"
@ -417,7 +417,7 @@ class ModelLoadCompleteEvent(ModelEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class ModelInstallDownloadProgressEvent(ModelEventBase):
"""Emitted at intervals while the install job is in progress (remote models only)."""
"""Event model for model_install_download_progress"""
__event_name__ = "model_install_download_progress"
@ -467,7 +467,7 @@ class ModelInstallDownloadsCompleteEvent(ModelEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class ModelInstallStartedEvent(ModelEventBase):
"""Emitted once when an install job becomes active."""
"""Event model for model_install_started"""
__event_name__ = "model_install_started"
@ -481,7 +481,7 @@ class ModelInstallStartedEvent(ModelEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class ModelInstallCompleteEvent(ModelEventBase):
"""Emitted when an install job is completed successfully."""
"""Event model for model_install_complete"""
__event_name__ = "model_install_complete"
@ -498,7 +498,7 @@ class ModelInstallCompleteEvent(ModelEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class ModelInstallCancelledEvent(ModelEventBase):
"""Emitted when an install job is cancelled."""
"""Event model for model_install_cancelled"""
__event_name__ = "model_install_cancelled"
@ -512,7 +512,7 @@ class ModelInstallCancelledEvent(ModelEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class ModelInstallErrorEvent(ModelEventBase):
"""Emitted when an install job encounters an exception."""
"""Event model for model_install_error"""
__event_name__ = "model_install_error"
@ -538,7 +538,7 @@ class BulkDownloadEventBase(EventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class BulkDownloadStartedEvent(BulkDownloadEventBase):
"""Emitted when a bulk image download is started"""
"""Event model for bulk_download_started"""
__event_name__ = "bulk_download_started"
@ -555,7 +555,7 @@ class BulkDownloadStartedEvent(BulkDownloadEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class BulkDownloadCompleteEvent(BulkDownloadEventBase):
"""Emitted when a bulk image download is started"""
"""Event model for bulk_download_complete"""
__event_name__ = "bulk_download_complete"
@ -572,7 +572,7 @@ class BulkDownloadCompleteEvent(BulkDownloadEventBase):
@payload_schema.register # pyright: ignore [reportUnknownMemberType]
class BulkDownloadErrorEvent(BulkDownloadEventBase):
"""Emitted when a bulk image download is started"""
"""Event model for bulk_download_error"""
__event_name__ = "bulk_download_error"