Skip to content

Commit 23cb991

Browse files
Copilotlmangani
andcommitted
fix: resolve 2 CI test failures (pyright errors + Darwin MPS policy test)
Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
1 parent 7d7fbcc commit 23cb991

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

backend/handlers/job_executors.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
from __future__ import annotations
44

55
import logging
6-
from typing import TYPE_CHECKING, Any
6+
from typing import TYPE_CHECKING, Any, Literal, cast
77

88
from api_types import (
99
GenerateImageRequest,
1010
GenerateVideoRequest,
11+
VideoCameraMotion,
1112
)
1213
from state.job_queue import QueueJob
1314

@@ -23,11 +24,14 @@ def _str(params: dict[str, Any], key: str, default: str = "") -> str:
2324
return str(v) if v is not None else default
2425

2526

26-
def _bool(params: dict[str, Any], key: str, default: bool = False) -> bool:
27-
v = params.get(key, default)
28-
if isinstance(v, bool):
29-
return v
30-
return str(v).lower() in ("1", "true", "yes", "on")
27+
def _camera_motion(params: dict[str, Any]) -> VideoCameraMotion:
28+
"""Return the cameraMotion param, defaulting to 'none'. Cast is safe: values come from validated queue jobs."""
29+
return cast(VideoCameraMotion, _str(params, "cameraMotion", "none"))
30+
31+
32+
def _aspect_ratio(params: dict[str, Any]) -> Literal["16:9", "9:16"]:
33+
"""Return the aspectRatio param, defaulting to '16:9'. Cast is safe: values come from validated queue jobs."""
34+
return cast(Literal["16:9", "9:16"], _str(params, "aspectRatio", "16:9"))
3135

3236

3337
def _int(params: dict[str, Any], key: str, default: int = 0) -> int:
@@ -65,8 +69,8 @@ def _execute_video(self, job: QueueJob) -> list[str]:
6569
duration=_str(p, "duration", "5"),
6670
fps=_str(p, "fps", "24"),
6771
audio=_str(p, "audio", "false"),
68-
cameraMotion=_str(p, "cameraMotion", "none"),
69-
aspectRatio=_str(p, "aspectRatio", "16:9"),
72+
cameraMotion=_camera_motion(p),
73+
aspectRatio=_aspect_ratio(p),
7074
model=job.model,
7175
negativePrompt=_str(p, "negativePrompt"),
7276
)
@@ -123,8 +127,8 @@ def execute(self, job: QueueJob) -> list[str]:
123127
duration=_str(p, "duration", "5"),
124128
fps=_str(p, "fps", "24"),
125129
audio=_str(p, "audio", "false"),
126-
cameraMotion=_str(p, "cameraMotion", "none"),
127-
aspectRatio=_str(p, "aspectRatio", "16:9"),
130+
cameraMotion=_camera_motion(p),
131+
aspectRatio=_aspect_ratio(p),
128132
model=job.model,
129133
negativePrompt=_str(p, "negativePrompt"),
130134
)

backend/tests/test_runtime_policy_decision.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
from runtime_config.runtime_policy import decide_force_api_generations
66

77

8-
def test_darwin_always_forces_api() -> None:
9-
assert decide_force_api_generations(system="Darwin", cuda_available=True, vram_gb=24) is True
10-
assert decide_force_api_generations(system="Darwin", cuda_available=False, vram_gb=None) is True
8+
def test_darwin_allows_local_mps_generation() -> None:
9+
# Darwin supports MPS (Apple Silicon GPU), so local generation is allowed.
10+
assert decide_force_api_generations(system="Darwin", cuda_available=True, vram_gb=24) is False
11+
assert decide_force_api_generations(system="Darwin", cuda_available=False, vram_gb=None) is False
1112

1213

1314
def test_windows_without_cuda_forces_api() -> None:

0 commit comments

Comments
 (0)