From 5d03328dc68acb1179d664feb85159fee02c665d Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Wed, 15 Jan 2025 09:06:50 +1100 Subject: [PATCH] tidy(nodes): code dedupe for batch node init errors --- invokeai/app/invocations/batch.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/invokeai/app/invocations/batch.py b/invokeai/app/invocations/batch.py index 1f85ba2735..14b9033864 100644 --- a/invokeai/app/invocations/batch.py +++ b/invokeai/app/invocations/batch.py @@ -23,6 +23,13 @@ BATCH_GROUP_IDS = Literal[ ] +class NotExecutableNodeError(Exception): + def __init__(self, message: str = "This class should never be executed or instantiated directly."): + super().__init__(message) + + pass + + class BaseBatchInvocation(BaseInvocation): batch_group_id: BATCH_GROUP_IDS = InputField( default="None", @@ -32,7 +39,7 @@ class BaseBatchInvocation(BaseInvocation): ) def __init__(self): - raise NotImplementedError("This class should never be executed or instantiated directly.") + raise NotExecutableNodeError() @invocation( @@ -51,7 +58,7 @@ class ImageBatchInvocation(BaseBatchInvocation): ) def invoke(self, context: InvocationContext) -> ImageOutput: - raise NotImplementedError("This class should never be executed or instantiated directly.") + raise NotExecutableNodeError() @invocation( @@ -70,7 +77,7 @@ class StringBatchInvocation(BaseBatchInvocation): ) def invoke(self, context: InvocationContext) -> StringOutput: - raise NotImplementedError("This class should never be executed or instantiated directly.") + raise NotExecutableNodeError() @invocation( @@ -89,7 +96,7 @@ class IntegerBatchInvocation(BaseBatchInvocation): ) def invoke(self, context: InvocationContext) -> IntegerOutput: - raise NotImplementedError("This class should never be executed or instantiated directly.") + raise NotExecutableNodeError() @invocation( @@ -108,4 +115,4 @@ class FloatBatchInvocation(BaseBatchInvocation): ) def invoke(self, context: InvocationContext) -> FloatOutput: - raise NotImplementedError("This class should never be executed or instantiated directly.") + raise NotExecutableNodeError()