mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(nodes): add boards interface to invocation context
This commit is contained in:
parent
4ce21087d3
commit
95dd5aad16
@ -7,6 +7,7 @@ from pydantic import ConfigDict
|
|||||||
from torch import Tensor
|
from torch import Tensor
|
||||||
|
|
||||||
from invokeai.app.invocations.fields import MetadataField, WithMetadata
|
from invokeai.app.invocations.fields import MetadataField, WithMetadata
|
||||||
|
from invokeai.app.services.boards.boards_common import BoardDTO
|
||||||
from invokeai.app.services.config.config_default import InvokeAIAppConfig
|
from invokeai.app.services.config.config_default import InvokeAIAppConfig
|
||||||
from invokeai.app.services.image_records.image_records_common import ImageCategory, ImageRecordChanges, ResourceOrigin
|
from invokeai.app.services.image_records.image_records_common import ImageCategory, ImageRecordChanges, ResourceOrigin
|
||||||
from invokeai.app.services.images.images_common import ImageDTO
|
from invokeai.app.services.images.images_common import ImageDTO
|
||||||
@ -63,6 +64,54 @@ class InvocationContextData:
|
|||||||
"""The workflow associated with this queue item, if any."""
|
"""The workflow associated with this queue item, if any."""
|
||||||
|
|
||||||
|
|
||||||
|
class BoardsInterface:
|
||||||
|
def __init__(self, services: InvocationServices) -> None:
|
||||||
|
def create(board_name: str) -> BoardDTO:
|
||||||
|
"""
|
||||||
|
Creates a board.
|
||||||
|
|
||||||
|
:param board_name: The name of the board to create.
|
||||||
|
"""
|
||||||
|
return services.boards.create(board_name)
|
||||||
|
|
||||||
|
def get_dto(board_id: str) -> BoardDTO:
|
||||||
|
"""
|
||||||
|
Gets a board DTO.
|
||||||
|
|
||||||
|
:param board_id: The ID of the board to get.
|
||||||
|
"""
|
||||||
|
return services.boards.get_dto(board_id)
|
||||||
|
|
||||||
|
def get_all() -> list[BoardDTO]:
|
||||||
|
"""
|
||||||
|
Gets all boards.
|
||||||
|
"""
|
||||||
|
return services.boards.get_all()
|
||||||
|
|
||||||
|
def add_image_to_board(board_id: str, image_name: str) -> None:
|
||||||
|
"""
|
||||||
|
Adds an image to a board.
|
||||||
|
|
||||||
|
:param board_id: The ID of the board to add the image to.
|
||||||
|
:param image_name: The name of the image to add to the board.
|
||||||
|
"""
|
||||||
|
services.board_images.add_image_to_board(board_id, image_name)
|
||||||
|
|
||||||
|
def get_all_image_names_for_board(board_id: str) -> list[str]:
|
||||||
|
"""
|
||||||
|
Gets all image names for a board.
|
||||||
|
|
||||||
|
:param board_id: The ID of the board to get the image names for.
|
||||||
|
"""
|
||||||
|
return services.board_images.get_all_board_image_names_for_board(board_id)
|
||||||
|
|
||||||
|
self.create = create
|
||||||
|
self.get_dto = get_dto
|
||||||
|
self.get_all = get_all
|
||||||
|
self.add_image_to_board = add_image_to_board
|
||||||
|
self.get_all_image_names_for_board = get_all_image_names_for_board
|
||||||
|
|
||||||
|
|
||||||
class LoggerInterface:
|
class LoggerInterface:
|
||||||
def __init__(self, services: InvocationServices) -> None:
|
def __init__(self, services: InvocationServices) -> None:
|
||||||
def debug(message: str) -> None:
|
def debug(message: str) -> None:
|
||||||
@ -427,6 +476,7 @@ class InvocationContext:
|
|||||||
logger: LoggerInterface,
|
logger: LoggerInterface,
|
||||||
config: ConfigInterface,
|
config: ConfigInterface,
|
||||||
util: UtilInterface,
|
util: UtilInterface,
|
||||||
|
boards: BoardsInterface,
|
||||||
data: InvocationContextData,
|
data: InvocationContextData,
|
||||||
services: InvocationServices,
|
services: InvocationServices,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -444,6 +494,8 @@ class InvocationContext:
|
|||||||
"""Provides access to the app's config."""
|
"""Provides access to the app's config."""
|
||||||
self.util = util
|
self.util = util
|
||||||
"""Provides utility methods."""
|
"""Provides utility methods."""
|
||||||
|
self.boards = boards
|
||||||
|
"""Provides methods to interact with boards."""
|
||||||
self.data = data
|
self.data = data
|
||||||
"""Provides data about the current queue item and invocation."""
|
"""Provides data about the current queue item and invocation."""
|
||||||
self.__services = services
|
self.__services = services
|
||||||
@ -554,6 +606,7 @@ def build_invocation_context(
|
|||||||
config = ConfigInterface(services=services)
|
config = ConfigInterface(services=services)
|
||||||
util = UtilInterface(services=services, context_data=context_data)
|
util = UtilInterface(services=services, context_data=context_data)
|
||||||
conditioning = ConditioningInterface(services=services, context_data=context_data)
|
conditioning = ConditioningInterface(services=services, context_data=context_data)
|
||||||
|
boards = BoardsInterface(services=services)
|
||||||
|
|
||||||
ctx = InvocationContext(
|
ctx = InvocationContext(
|
||||||
images=images,
|
images=images,
|
||||||
@ -565,6 +618,7 @@ def build_invocation_context(
|
|||||||
util=util,
|
util=util,
|
||||||
conditioning=conditioning,
|
conditioning=conditioning,
|
||||||
services=services,
|
services=services,
|
||||||
|
boards=boards,
|
||||||
)
|
)
|
||||||
|
|
||||||
return ctx
|
return ctx
|
||||||
|
Loading…
Reference in New Issue
Block a user