Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

feat(minimax-h3): frame count as a grid-aligned dropdown

Lincoln Steinb6fde79124c5
diff --git a/invokeai/app/invocations/minimax_h3_denoise.py b/invokeai/app/invocations/minimax_h3_denoise.py
index 652ef759e4..4c89aac8da 100644
--- a/invokeai/app/invocations/minimax_h3_denoise.py
+++ b/invokeai/app/invocations/minimax_h3_denoise.py
@@ -7,6 +7,7 @@ guidance-distilled: no negative prompt, no CFG, one forward per step.
"""
from contextlib import ExitStack
+from typing import Literal, get_args
import torch
from PIL import Image
@@ -35,6 +36,8 @@ from invokeai.backend.minimax_h3.denoise import denoise
from invokeai.backend.minimax_h3.int8_convrot import Int8ConvrotLinear
from invokeai.backend.minimax_h3.packing import (
MINIMAX_H3_CANVAS_MULTIPLE,
+ MINIMAX_H3_FPS,
+ MINIMAX_H3_VIDEO_FRAME_CHOICES,
MiniMaxH3PackedSequence,
audio_latent_num_frames,
unpack_audio_tokens,
@@ -49,6 +52,7 @@ from invokeai.backend.minimax_h3.pruned_adaln_lora import (
from invokeai.backend.minimax_h3.sampling import (
MINIMAX_H3_PATCH_SIZE,
MINIMAX_H3_SPATIAL_COMPRESSION,
+ MINIMAX_H3_STILL_NUM_FRAMES,
MINIMAX_H3_VAE_LATENT_CHANNELS,
build_denoise_state,
validate_num_frames,
@@ -71,6 +75,40 @@ from invokeai.backend.stable_diffusion.diffusers_pipeline import PipelineInterme
from invokeai.backend.stable_diffusion.diffusion.conditioning_data import MiniMaxH3ConditioningInfo
from invokeai.backend.util.devices import TorchDevice
+# The frame count is a choice list rather than a free integer: only `17n + 5` counts exist on the video VAE's
+# chunk grid, and a mistyped value used to surface as a validation error after the graph was already running.
+# The values are strings because that is the only enum shape both workflow editors render as a dropdown.
+MiniMaxH3NumFrames = Literal[
+ "5",
+ "90",
+ "107",
+ "124",
+ "141",
+ "158",
+ "175",
+ "192",
+ "209",
+ "226",
+ "243",
+ "260",
+ "277",
+ "294",
+ "311",
+ "328",
+ "345",
+]
+
+# Fail at import time if the grid constants and the Literal above ever drift apart.
+assert set(get_args(MiniMaxH3NumFrames)) == {
+ str(MINIMAX_H3_STILL_NUM_FRAMES),
+ *(str(n) for n in MINIMAX_H3_VIDEO_FRAME_CHOICES),
+}, "MiniMaxH3NumFrames is out of sync with the 17n+5 frame grid."
+
+MINIMAX_H3_NUM_FRAMES_LABELS: dict[str, str] = {
+ str(MINIMAX_H3_STILL_NUM_FRAMES): f"{MINIMAX_H3_STILL_NUM_FRAMES} - still image only",
+ **{str(n): f"{n} frames - {n / MINIMAX_H3_FPS:.2f} s" for n in MINIMAX_H3_VIDEO_FRAME_CHOICES},
+}
+
@invocation_output("minimax_h3_denoise_output")
class MiniMaxH3DenoiseOutput(BaseInvocationOutput):
@@ -90,7 +128,7 @@ class MiniMaxH3DenoiseOutput(BaseInvocationOutput):
title="Denoise - MiniMax H3",
tags=["latents", "video", "audio", "minimax"],
category="latents",
- version="1.2.0",
+ version="1.3.0",
classification=Classification.Prototype,
)
class MiniMaxH3DenoiseInvocation(BaseInvocation):
@@ -120,13 +158,14 @@ class MiniMaxH3DenoiseInvocation(BaseInvocation):
multiple_of=MINIMAX_H3_CANVAS_MULTIPLE,
description="Height of the generated video.",
)
- num_frames: int = InputField(
- default=124,
- ge=5,
- description="Number of output frames at the fixed 24 fps. Must be of the form 17n+5 "
- "(5, 22, ..., 124, ...); durations must stay within 5-15 s, except exactly 5 frames "
- "for a still image.",
+ num_frames: MiniMaxH3NumFrames = InputField(
+ default="124",
+ description="Number of output frames at the fixed 24 fps. Only the video VAE's 17n+5 grid points are "
+ "offered: 90 (3.75 s) through 345 (14.38 s), plus the single 5-frame block used by the still-image "
+ "path. The model was trained for 5-15 s, so counts below 124 are usable but off-distribution - handy "
+ "for quick test renders.",
title="Number of Frames",
+ ui_choice_labels=MINIMAX_H3_NUM_FRAMES_LABELS,
)
steps: int = InputField(
default=50,
@@ -185,7 +224,10 @@ class MiniMaxH3DenoiseInvocation(BaseInvocation):
@torch.no_grad()
def invoke(self, context: InvocationContext) -> MiniMaxH3DenoiseOutput:
- validate_num_frames(self.num_frames)
+ # The field is a choice list of grid-aligned strings; validate anyway so a hand-authored graph that
+ # bypasses the dropdown still fails here rather than deep in the VAE.
+ num_frames = int(self.num_frames)
+ validate_num_frames(num_frames)
device = TorchDevice.choose_torch_device()
@@ -196,8 +238,8 @@ class MiniMaxH3DenoiseInvocation(BaseInvocation):
latent_height = self.height // MINIMAX_H3_SPATIAL_COMPRESSION
latent_width = self.width // MINIMAX_H3_SPATIAL_COMPRESSION
- num_latent_frames = video_latent_num_frames(self.num_frames)
- num_audio_latents = audio_latent_num_frames(self.num_frames)
+ num_latent_frames = video_latent_num_frames(num_frames)
+ num_audio_latents = audio_latent_num_frames(num_frames)
keyframe_anchors: tuple[str, ...] = ()
clean_condition_rows: torch.Tensor | None = None
@@ -371,7 +413,7 @@ class MiniMaxH3DenoiseInvocation(BaseInvocation):
)
context.util.signal_progress("Denoising MiniMax H3 audio-video")
# steps counts sigma grid points (terminal included) -> steps-1 model evaluations.
- progress = tqdm(total=len(state.timesteps), desc=f"Denoising MiniMax H3 ({self.num_frames} frames)")
+ progress = tqdm(total=len(state.timesteps), desc=f"Denoising MiniMax H3 ({num_frames} frames)")
def callback_with_progress(step: int, total_steps: int, pred_x0_video_rows: torch.Tensor) -> None:
progress.update(1)
@@ -408,7 +450,7 @@ class MiniMaxH3DenoiseInvocation(BaseInvocation):
audio_latents=LatentsField(latents_name=audio_name, seed=self.seed),
width=self.width,
height=self.height,
- num_frames=self.num_frames,
+ num_frames=num_frames,
)
def _materialize_lora_patches(self, context: InvocationContext) -> list[PatchSpec]:
diff --git a/invokeai/app/services/workflow_records/default_workflows/First Frame to Video - MiniMax H3.json b/invokeai/app/services/workflow_records/default_workflows/First Frame to Video - MiniMax H3.json
index 6ce5508c2d..b375cb5516 100644
--- a/invokeai/app/services/workflow_records/default_workflows/First Frame to Video - MiniMax H3.json
+++ b/invokeai/app/services/workflow_records/default_workflows/First Frame to Video - MiniMax H3.json
@@ -234,7 +234,7 @@
"type": "invocation",
"data": {
"id": "9d3b9faf-405b-7e6f-bf4d-5c6a7f8e9d04",
- "version": "1.2.0",
+ "version": "1.3.0",
"nodePack": "invokeai",
"label": "",
"notes": "",
@@ -270,8 +270,8 @@
"num_frames": {
"name": "num_frames",
"label": "Frames",
- "description": "Frame count must be 5 more than a multiple of 17 (124, 141, ..., 345). 124 frames = ~5.2 s at the fixed 24 fps; the maximum is 345 (14.4 s).",
- "value": 124
+ "description": "",
+ "value": "124"
},
"steps": {
"name": "steps",
diff --git a/invokeai/app/services/workflow_records/default_workflows/Text to Video - MiniMax H3.json b/invokeai/app/services/workflow_records/default_workflows/Text to Video - MiniMax H3.json
index 25e5743164..6bf05ec844 100644
--- a/invokeai/app/services/workflow_records/default_workflows/Text to Video - MiniMax H3.json
+++ b/invokeai/app/services/workflow_records/default_workflows/Text to Video - MiniMax H3.json
@@ -156,7 +156,7 @@
"type": "invocation",
"data": {
"id": "9d3b9faf-405b-7e6f-bf4d-5c6a7f8e9d04",
- "version": "1.2.0",
+ "version": "1.3.0",
"nodePack": "invokeai",
"label": "",
"notes": "",
@@ -192,8 +192,8 @@
"num_frames": {
"name": "num_frames",
"label": "Frames",
- "description": "Frame count must be 5 more than a multiple of 17 (124, 141, ..., 345). 124 frames = ~5.2 s at the fixed 24 fps; the maximum is 345 (14.4 s).",
- "value": 124
+ "description": "",
+ "value": "124"
},
"steps": {
"name": "steps",
diff --git a/invokeai/backend/minimax_h3/packing.py b/invokeai/backend/minimax_h3/packing.py
index e03123aa45..53ae0ccc32 100644
--- a/invokeai/backend/minimax_h3/packing.py
+++ b/invokeai/backend/minimax_h3/packing.py
@@ -59,11 +59,24 @@ MINIMAX_H3_MAX_ASPECT_RATIO = 4
MINIMAX_H3_MIN_DURATION = 5.0
MINIMAX_H3_MAX_DURATION = 15.0
+# The released model targets the 5-15 s window above, but shorter grid-aligned clips render and are useful as fast
+# test passes. 90 frames (3.75 s) is the floor we accept for video requests; below that only the 5-frame
+# still-image block is meaningful.
+MINIMAX_H3_MIN_VIDEO_FRAMES = 90
+
# The video VAE encodes 17 pixel frames per chunk and drops the 3 trailing latent frames of every chunk, so
# `17 * n + 5` pixel frames map to `5 * n + 2` latent frames.
MINIMAX_H3_FRAMES_PER_CHUNK = 17
MINIMAX_H3_LATENTS_PER_CHUNK = 5
+# Every legal video frame count, i.e. the `17n + 5` grid points from the accepted floor up to the 15 s ceiling
+# (90 ... 345). The nodes offer exactly these as a choice list, so a request can never miss the grid.
+MINIMAX_H3_VIDEO_FRAME_CHOICES = tuple(
+ n
+ for n in range(MINIMAX_H3_MIN_VIDEO_FRAMES, int(MINIMAX_H3_MAX_DURATION * MINIMAX_H3_FPS) + 1)
+ if n % MINIMAX_H3_FRAMES_PER_CHUNK == MINIMAX_H3_LATENTS_PER_CHUNK
+)
+
# The pixel convention of the video VAE: ImageNet-normalized RGB over a `[0, 1]` base range.
MINIMAX_H3_PIXEL_MEAN = (0.485, 0.456, 0.406)
MINIMAX_H3_PIXEL_STD = (0.229, 0.224, 0.225)
diff --git a/invokeai/backend/minimax_h3/sampling.py b/invokeai/backend/minimax_h3/sampling.py
index 3994f7db85..8ae8863c57 100644
--- a/invokeai/backend/minimax_h3/sampling.py
+++ b/invokeai/backend/minimax_h3/sampling.py
@@ -24,7 +24,7 @@ from invokeai.backend.minimax_h3.packing import (
MINIMAX_H3_KEYFRAME_NOISE_AUG,
MINIMAX_H3_LATENTS_PER_CHUNK,
MINIMAX_H3_MAX_DURATION,
- MINIMAX_H3_MIN_DURATION,
+ MINIMAX_H3_MIN_VIDEO_FRAMES,
MiniMaxH3PackedSequence,
build_packed_sequence,
build_row_timesteps,
@@ -54,9 +54,10 @@ MINIMAX_H3_STILL_NUM_FRAMES = 5
def validate_num_frames(num_frames: int) -> None:
"""Reject frame counts the FL2VA checkpoint cannot generate.
- Valid values are ``17 * n + 5`` (the video VAE's chunk grid). The resulting duration must
- lie in the released model's 5-15 s window — except for the single-block minimum of 5 frames,
- which is allowed as the still-image (frame-extraction) path.
+ Valid values are ``17 * n + 5`` (the video VAE's chunk grid), from 90 frames (3.75 s — below
+ the released 5 s training window, but accepted for fast test renders) up to the model's 15 s
+ ceiling — except for the single-block minimum of 5 frames, which is allowed as the
+ still-image (frame-extraction) path.
"""
if num_frames % MINIMAX_H3_FRAMES_PER_CHUNK != MINIMAX_H3_LATENTS_PER_CHUNK:
raise ValueError(
@@ -66,12 +67,13 @@ def validate_num_frames(num_frames: int) -> None:
if num_frames == MINIMAX_H3_STILL_NUM_FRAMES:
return
duration = num_frames / MINIMAX_H3_FPS
- if not MINIMAX_H3_MIN_DURATION <= duration <= MINIMAX_H3_MAX_DURATION:
+ if num_frames < MINIMAX_H3_MIN_VIDEO_FRAMES or duration > MINIMAX_H3_MAX_DURATION:
raise ValueError(
- f"MiniMax H3 generates between {MINIMAX_H3_MIN_DURATION:g} and {MINIMAX_H3_MAX_DURATION:g} "
- f"seconds at {MINIMAX_H3_FPS} fps ({int(MINIMAX_H3_MIN_DURATION * MINIMAX_H3_FPS)}-"
- f"{int(MINIMAX_H3_MAX_DURATION * MINIMAX_H3_FPS)} frames on the 17n+5 grid), or exactly "
- f"{MINIMAX_H3_STILL_NUM_FRAMES} frames for a still image; got {num_frames}."
+ f"MiniMax H3 video requests must be between {MINIMAX_H3_MIN_VIDEO_FRAMES} and "
+ f"{int(MINIMAX_H3_MAX_DURATION * MINIMAX_H3_FPS)} frames on the 17n+5 grid "
+ f"({MINIMAX_H3_MIN_VIDEO_FRAMES / MINIMAX_H3_FPS:g}-{MINIMAX_H3_MAX_DURATION:g} seconds at "
+ f"{MINIMAX_H3_FPS} fps), or exactly {MINIMAX_H3_STILL_NUM_FRAMES} frames for a still image; "
+ f"got {num_frames}."
)
diff --git a/invokeai/frontend/web/openapi.json b/invokeai/frontend/web/openapi.json
index 06697020eb..f2768826a9 100644
--- a/invokeai/frontend/web/openapi.json
+++ b/invokeai/frontend/web/openapi.json
@@ -66032,15 +66032,52 @@
"type": "integer"
},
"num_frames": {
- "default": 124,
- "description": "Number of output frames at the fixed 24 fps. Must be of the form 17n+5 (5, 22, ..., 124, ...); durations must stay within 5-15 s, except exactly 5 frames for a still image.",
- "field_kind": "input",
- "input": "any",
- "minimum": 5,
- "orig_default": 124,
+ "default": "124",
+ "description": "Number of output frames at the fixed 24 fps. Only the video VAE's 17n+5 grid points are offered: 90 (3.75 s) through 345 (14.38 s), plus the single 5-frame block used by the still-image path. The model was trained for 5-15 s, so counts below 124 are usable but off-distribution - handy for quick test renders.",
+ "enum": [
+ "5",
+ "90",
+ "107",
+ "124",
+ "141",
+ "158",
+ "175",
+ "192",
+ "209",
+ "226",
+ "243",
+ "260",
+ "277",
+ "294",
+ "311",
+ "328",
+ "345"
+ ],
+ "field_kind": "input",
+ "input": "any",
+ "orig_default": "124",
"orig_required": false,
"title": "Number of Frames",
- "type": "integer"
+ "type": "string",
+ "ui_choice_labels": {
+ "107": "107 frames - 4.46 s",
+ "124": "124 frames - 5.17 s",
+ "141": "141 frames - 5.88 s",
+ "158": "158 frames - 6.58 s",
+ "175": "175 frames - 7.29 s",
+ "192": "192 frames - 8.00 s",
+ "209": "209 frames - 8.71 s",
+ "226": "226 frames - 9.42 s",
+ "243": "243 frames - 10.12 s",
+ "260": "260 frames - 10.83 s",
+ "277": "277 frames - 11.54 s",
+ "294": "294 frames - 12.25 s",
+ "311": "311 frames - 12.96 s",
+ "328": "328 frames - 13.67 s",
+ "345": "345 frames - 14.38 s",
+ "5": "5 - still image only",
+ "90": "90 frames - 3.75 s"
+ }
},
"steps": {
"default": 50,
@@ -66075,7 +66112,7 @@
"tags": ["latents", "video", "audio", "minimax"],
"title": "Denoise - MiniMax H3",
"type": "object",
- "version": "1.2.0",
+ "version": "1.3.0",
"output": {
"$ref": "#/components/schemas/MiniMaxH3DenoiseOutput"
}
diff --git a/invokeai/frontend/web/src/features/nodes/util/graph/generation/buildMiniMaxH3Graph.ts b/invokeai/frontend/web/src/features/nodes/util/graph/generation/buildMiniMaxH3Graph.ts
index 3e397d8291..6b4dfab3a3 100644
--- a/invokeai/frontend/web/src/features/nodes/util/graph/generation/buildMiniMaxH3Graph.ts
+++ b/invokeai/frontend/web/src/features/nodes/util/graph/generation/buildMiniMaxH3Graph.ts
@@ -32,7 +32,7 @@ const MINIMAX_H3_FPS = 24;
* for the still-image output mode. */
const MINIMAX_H3_MIN_VIDEO_FRAMES = 124;
const MINIMAX_H3_MAX_VIDEO_FRAMES = 345;
-const MINIMAX_H3_IMAGE_FRAMES = 5;
+const MINIMAX_H3_IMAGE_FRAMES = '5' as const;
/**
* Snap a duration in seconds to the nearest legal MiniMax H3 frame count (17n+5), clamped to
@@ -173,7 +173,8 @@ export const buildMiniMaxH3Graph = async (arg: GraphBuilderArg): Promise<GraphBu
g.updateNode(denoise, {
width: originalSize.width,
height: originalSize.height,
- num_frames,
+ // The node takes the frame count as a grid-aligned choice value, not a free integer.
+ num_frames: `${num_frames}` as Invocation<'minimax_h3_denoise'>['num_frames'],
});
// The keyframe vision context is prepared on the same canvas as the condition rows.
g.updateNode(posCond, {
diff --git a/invokeai/frontend/web/src/services/api/schema.ts b/invokeai/frontend/web/src/services/api/schema.ts
index 6bec9614e7..2a47c28923 100644
--- a/invokeai/frontend/web/src/services/api/schema.ts
+++ b/invokeai/frontend/web/src/services/api/schema.ts
@@ -27781,10 +27781,11 @@ export type components = {
height?: number;
/**
* Number of Frames
- * @description Number of output frames at the fixed 24 fps. Must be of the form 17n+5 (5, 22, ..., 124, ...); durations must stay within 5-15 s, except exactly 5 frames for a still image.
+ * @description Number of output frames at the fixed 24 fps. Only the video VAE's 17n+5 grid points are offered: 90 (3.75 s) through 345 (14.38 s), plus the single 5-frame block used by the still-image path. The model was trained for 5-15 s, so counts below 124 are usable but off-distribution - handy for quick test renders.
* @default 124
+ * @enum {string}
*/
- num_frames?: number;
+ num_frames?: "5" | "90" | "107" | "124" | "141" | "158" | "175" | "192" | "209" | "226" | "243" | "260" | "277" | "294" | "311" | "328" | "345";
/**
* Steps
* @description Number of denoising steps (sigma grid points, terminal included: N steps = N-1 model evaluations).
diff --git a/tests/app/invocations/test_minimax_h3_denoise_num_frames.py b/tests/app/invocations/test_minimax_h3_denoise_num_frames.py
new file mode 100644
index 0000000000..1cf3ec2e6e
--- /dev/null
+++ b/tests/app/invocations/test_minimax_h3_denoise_num_frames.py
@@ -0,0 +1,68 @@
+"""The MiniMax H3 denoise node's frame count is a choice list, not a free integer.
+
+Only `17n + 5` counts exist on the video VAE's chunk grid, so the node offers them as an enum
+(strings, the only enum shape both workflow editors render as a dropdown) and converts to an int
+at invoke time.
+"""
+
+import pytest
+from pydantic import ValidationError
+
+from invokeai.app.invocations.minimax_h3_denoise import (
+ MINIMAX_H3_NUM_FRAMES_LABELS,
+ MiniMaxH3DenoiseInvocation,
+)
+from invokeai.backend.minimax_h3.packing import MINIMAX_H3_VIDEO_FRAME_CHOICES
+from invokeai.backend.minimax_h3.sampling import MINIMAX_H3_STILL_NUM_FRAMES, validate_num_frames
+
+
+def _node(**kwargs) -> MiniMaxH3DenoiseInvocation:
+ return MiniMaxH3DenoiseInvocation(id="denoise", **kwargs)
+
+
+def test_default_is_the_five_second_grid_point():
+ assert _node().num_frames == "124"
+
+
[email protected]("frames", MINIMAX_H3_VIDEO_FRAME_CHOICES)
+def test_every_video_choice_is_accepted_and_valid(frames: int):
+ node = _node(num_frames=str(frames))
+ # The stored value round-trips to the int the denoise loop uses, and clears its own validator.
+ assert int(node.num_frames) == frames
+ validate_num_frames(int(node.num_frames))
+
+
+def test_still_image_block_is_offered():
+ # The linear UI's image output mode sets exactly this value; dropping it would break that path.
+ assert _node(num_frames=str(MINIMAX_H3_STILL_NUM_FRAMES)).num_frames == "5"
+
+
[email protected]("value", ["6", "121", "362", "89", "1024", "", "124 frames"])
+def test_off_grid_and_out_of_range_values_are_rejected(value: str):
+ with pytest.raises(ValidationError):
+ _node(num_frames=value)
+
+
+def test_integer_values_are_rejected():
+ # An old graph carrying `num_frames: 124` must fail loudly at graph validation rather than
+ # silently coercing (pydantic does not coerce int -> str Literal in lax mode).
+ with pytest.raises(ValidationError):
+ _node(num_frames=124)
+
+
+def test_labels_cover_every_choice_and_name_the_duration():
+ assert set(MINIMAX_H3_NUM_FRAMES_LABELS) == {
+ str(MINIMAX_H3_STILL_NUM_FRAMES),
+ *(str(n) for n in MINIMAX_H3_VIDEO_FRAME_CHOICES),
+ }
+ assert MINIMAX_H3_NUM_FRAMES_LABELS["124"] == "124 frames - 5.17 s"
+ assert MINIMAX_H3_NUM_FRAMES_LABELS["90"] == "90 frames - 3.75 s"
+ assert "still image" in MINIMAX_H3_NUM_FRAMES_LABELS["5"]
+
+
+def test_choices_appear_in_the_generated_json_schema():
+ schema = MiniMaxH3DenoiseInvocation.model_json_schema()
+ num_frames = schema["properties"]["num_frames"]
+ # ui_choice_labels rides along so the editors can show "124 frames - 5.17 s".
+ assert num_frames["ui_choice_labels"] == MINIMAX_H3_NUM_FRAMES_LABELS
+ assert num_frames.get("default") == "124"
diff --git a/tests/backend/minimax_h3/test_sampling.py b/tests/backend/minimax_h3/test_sampling.py
index b0f7d30125..818806f6f6 100644
--- a/tests/backend/minimax_h3/test_sampling.py
+++ b/tests/backend/minimax_h3/test_sampling.py
@@ -4,6 +4,7 @@ import pytest
import torch
from invokeai.backend.minimax_h3.packing import (
+ MINIMAX_H3_VIDEO_FRAME_CHOICES,
align_num_frames,
audio_latent_num_frames,
resolve_canvas_size,
@@ -15,8 +16,9 @@ from invokeai.backend.minimax_h3.sampling import build_denoise_state, validate_n
class TestFrameGrid:
def test_legal_frame_counts_pass(self):
- # 345 = 17*20+5 (14.375 s) is the longest legal clip: 362 rounds past the 15 s cap.
- for n in (5, 124, 141, 345):
+ # 90 (3.75 s) is the accepted floor for video; 345 = 17*20+5 (14.375 s) is the longest legal
+ # clip, since 362 rounds past the 15 s cap.
+ for n in (5, 90, 107, 124, 141, 345):
validate_num_frames(n)
def test_misaligned_frame_counts_rejected(self):
@@ -25,18 +27,29 @@ class TestFrameGrid:
with pytest.raises(ValueError, match="17"):
validate_num_frames(121)
- def test_durations_outside_window_rejected(self):
- # 22/39/107 frames are grid-aligned but below the 5 s floor (and not the still path).
- for n in (22, 39, 107):
- with pytest.raises(ValueError, match="seconds"):
+ def test_frame_counts_outside_the_accepted_range_rejected(self):
+ # 22/39/56/73 are grid-aligned but below the 90-frame floor (and not the still path).
+ for n in (22, 39, 56, 73):
+ with pytest.raises(ValueError, match="frames on the 17n"):
validate_num_frames(n)
# 362 = 17*21+5 is aligned but 15.083 s > 15 s.
- with pytest.raises(ValueError, match="seconds"):
+ with pytest.raises(ValueError, match="frames on the 17n"):
validate_num_frames(362)
def test_still_image_minimum_allowed(self):
validate_num_frames(5)
+ def test_every_offered_choice_validates(self):
+ # The node's dropdown is built from this tuple; nothing in it may be rejected at invoke time.
+ assert MINIMAX_H3_VIDEO_FRAME_CHOICES[0] == 90
+ assert MINIMAX_H3_VIDEO_FRAME_CHOICES[-1] == 345
+ for n in MINIMAX_H3_VIDEO_FRAME_CHOICES:
+ validate_num_frames(n)
+
+ def test_choices_are_exactly_the_grid_points_in_range(self):
+ expected = tuple(n for n in range(90, 361) if n % 17 == 5)
+ assert MINIMAX_H3_VIDEO_FRAME_CHOICES == expected
+
def test_align_num_frames(self):
assert align_num_frames(121) == 124
assert align_num_frames(5) == 5