feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
from typing import Any, Callable, Union
|
2023-08-17 22:45:25 +00:00
|
|
|
from pydantic import Field
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
from invokeai.app.invocations.baseinvocation import (
|
|
|
|
BaseInvocation,
|
|
|
|
BaseInvocationOutput,
|
|
|
|
InvocationContext,
|
|
|
|
invocation,
|
|
|
|
invocation_output,
|
|
|
|
)
|
2023-03-03 05:02:15 +00:00
|
|
|
from invokeai.app.invocations.image import ImageField
|
2022-12-01 05:33:20 +00:00
|
|
|
|
2023-07-27 14:54:01 +00:00
|
|
|
|
2022-12-01 05:33:20 +00:00
|
|
|
# Define test invocations before importing anything that uses invocations
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation_output("test_list_output")
|
2022-12-01 05:33:20 +00:00
|
|
|
class ListPassThroughInvocationOutput(BaseInvocationOutput):
|
|
|
|
collection: list[ImageField] = Field(default_factory=list)
|
|
|
|
|
2023-07-27 14:54:01 +00:00
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation("test_list")
|
2022-12-01 05:33:20 +00:00
|
|
|
class ListPassThroughInvocation(BaseInvocation):
|
|
|
|
collection: list[ImageField] = Field(default_factory=list)
|
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> ListPassThroughInvocationOutput:
|
2023-07-27 14:54:01 +00:00
|
|
|
return ListPassThroughInvocationOutput(collection=self.collection)
|
|
|
|
|
2022-12-01 05:33:20 +00:00
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation_output("test_prompt_output")
|
2022-12-01 05:33:20 +00:00
|
|
|
class PromptTestInvocationOutput(BaseInvocationOutput):
|
2023-07-27 14:54:01 +00:00
|
|
|
prompt: str = Field(default="")
|
2022-12-01 05:33:20 +00:00
|
|
|
|
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation("test_prompt")
|
2022-12-01 05:33:20 +00:00
|
|
|
class PromptTestInvocation(BaseInvocation):
|
2023-07-27 14:54:01 +00:00
|
|
|
prompt: str = Field(default="")
|
2022-12-01 05:33:20 +00:00
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> PromptTestInvocationOutput:
|
2023-07-27 14:54:01 +00:00
|
|
|
return PromptTestInvocationOutput(prompt=self.prompt)
|
|
|
|
|
2022-12-01 05:33:20 +00:00
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation("test_error")
|
2023-02-27 18:01:07 +00:00
|
|
|
class ErrorInvocation(BaseInvocation):
|
|
|
|
def invoke(self, context: InvocationContext) -> PromptTestInvocationOutput:
|
|
|
|
raise Exception("This invocation is supposed to fail")
|
|
|
|
|
2023-07-27 14:54:01 +00:00
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation_output("test_image_output")
|
2022-12-01 05:33:20 +00:00
|
|
|
class ImageTestInvocationOutput(BaseInvocationOutput):
|
|
|
|
image: ImageField = Field()
|
|
|
|
|
2023-07-27 14:54:01 +00:00
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation("test_text_to_image")
|
2023-06-29 06:01:17 +00:00
|
|
|
class TextToImageTestInvocation(BaseInvocation):
|
2023-07-27 14:54:01 +00:00
|
|
|
prompt: str = Field(default="")
|
2022-12-01 05:33:20 +00:00
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> ImageTestInvocationOutput:
|
2023-05-25 00:23:25 +00:00
|
|
|
return ImageTestInvocationOutput(image=ImageField(image_name=self.id))
|
2022-12-01 05:33:20 +00:00
|
|
|
|
2023-07-27 14:54:01 +00:00
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation("test_image_to_image")
|
2023-06-29 06:01:17 +00:00
|
|
|
class ImageToImageTestInvocation(BaseInvocation):
|
2023-07-27 14:54:01 +00:00
|
|
|
prompt: str = Field(default="")
|
2023-06-29 06:01:17 +00:00
|
|
|
image: Union[ImageField, None] = Field(default=None)
|
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> ImageTestInvocationOutput:
|
|
|
|
return ImageTestInvocationOutput(image=ImageField(image_name=self.id))
|
|
|
|
|
2023-07-27 14:54:01 +00:00
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation_output("test_prompt_collection_output")
|
2022-12-01 05:33:20 +00:00
|
|
|
class PromptCollectionTestInvocationOutput(BaseInvocationOutput):
|
|
|
|
collection: list[str] = Field(default_factory=list)
|
|
|
|
|
2023-07-27 14:54:01 +00:00
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation("test_prompt_collection")
|
2022-12-01 05:33:20 +00:00
|
|
|
class PromptCollectionTestInvocation(BaseInvocation):
|
|
|
|
collection: list[str] = Field()
|
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> PromptCollectionTestInvocationOutput:
|
|
|
|
return PromptCollectionTestInvocationOutput(collection=self.collection.copy())
|
|
|
|
|
2023-07-27 14:54:01 +00:00
|
|
|
|
2023-08-18 00:55:55 +00:00
|
|
|
# Importing these at the top breaks previous tests
|
|
|
|
from invokeai.app.services.events import EventServiceBase # noqa: E402
|
|
|
|
from invokeai.app.services.graph import Edge, EdgeConnection # noqa: E402
|
|
|
|
|
|
|
|
|
2023-03-15 06:09:30 +00:00
|
|
|
def create_edge(from_id: str, from_field: str, to_id: str, to_field: str) -> Edge:
|
|
|
|
return Edge(
|
2023-07-27 14:54:01 +00:00
|
|
|
source=EdgeConnection(node_id=from_id, field=from_field),
|
|
|
|
destination=EdgeConnection(node_id=to_id, field=to_field),
|
|
|
|
)
|
2022-12-01 05:33:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestEvent:
|
|
|
|
event_name: str
|
|
|
|
payload: Any
|
|
|
|
|
|
|
|
def __init__(self, event_name: str, payload: Any):
|
|
|
|
self.event_name = event_name
|
|
|
|
self.payload = payload
|
|
|
|
|
2023-07-27 14:54:01 +00:00
|
|
|
|
2022-12-01 05:33:20 +00:00
|
|
|
class TestEventService(EventServiceBase):
|
|
|
|
events: list
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
|
|
|
self.events = list()
|
|
|
|
|
|
|
|
def dispatch(self, event_name: str, payload: Any) -> None:
|
|
|
|
pass
|
|
|
|
|
2023-07-27 14:54:01 +00:00
|
|
|
|
2022-12-01 05:33:20 +00:00
|
|
|
def wait_until(condition: Callable[[], bool], timeout: int = 10, interval: float = 0.1) -> None:
|
|
|
|
import time
|
2023-07-27 14:54:01 +00:00
|
|
|
|
2022-12-01 05:33:20 +00:00
|
|
|
start_time = time.time()
|
|
|
|
while time.time() - start_time < timeout:
|
|
|
|
if condition():
|
|
|
|
return
|
|
|
|
time.sleep(interval)
|
2023-03-03 05:02:15 +00:00
|
|
|
raise TimeoutError("Condition not met")
|