mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(nodes): add RangeInvocation validator
`stop` must be greater than `start`.
This commit is contained in:
parent
6f78c073ed
commit
55b3193629
@ -3,7 +3,7 @@
|
|||||||
from typing import Literal, Optional
|
from typing import Literal, Optional
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pydantic import Field
|
from pydantic import Field, validator
|
||||||
|
|
||||||
from invokeai.app.util.misc import SEED_MAX, get_random_seed
|
from invokeai.app.util.misc import SEED_MAX, get_random_seed
|
||||||
|
|
||||||
@ -33,6 +33,12 @@ class RangeInvocation(BaseInvocation):
|
|||||||
stop: int = Field(default=10, description="The stop of the range")
|
stop: int = Field(default=10, description="The stop of the range")
|
||||||
step: int = Field(default=1, description="The step of the range")
|
step: int = Field(default=1, description="The step of the range")
|
||||||
|
|
||||||
|
@validator("stop")
|
||||||
|
def stop_gt_start(cls, v, values):
|
||||||
|
if "start" in values and v <= values["start"]:
|
||||||
|
raise ValueError("stop must be greater than start")
|
||||||
|
return v
|
||||||
|
|
||||||
def invoke(self, context: InvocationContext) -> IntCollectionOutput:
|
def invoke(self, context: InvocationContext) -> IntCollectionOutput:
|
||||||
return IntCollectionOutput(
|
return IntCollectionOutput(
|
||||||
collection=list(range(self.start, self.stop, self.step))
|
collection=list(range(self.start, self.stop, self.step))
|
||||||
|
Loading…
Reference in New Issue
Block a user