Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

keep the MiniMax H3 keyframe preflight free of Pillow

[._.]/ Adam Eivy185d15787e37
diff --git a/scripts/generate_minimax_h3.py b/scripts/generate_minimax_h3.py
index 9b9c15ace8..ff43dd4fb8 100644
--- a/scripts/generate_minimax_h3.py
+++ b/scripts/generate_minimax_h3.py
@@ -209,14 +209,20 @@ def validate_args(args: argparse.Namespace) -> None:
def load_keyframes(paths: list[str]) -> list:
"""Open each conditioning image upright, in RGB, in the order given."""
+ # Every path is checked before anything is opened, so a bad second keyframe
+ # doesn't cost a decode of the first — and the message names the PortOS-side
+ # cause rather than surfacing Pillow's bare FileNotFoundError.
+ for path in paths:
+ if not Path(path).is_file():
+ raise RuntimeError(f"Conditioning image is missing: {path}")
+ # Imported only once there is something to decode: a text-only run never
+ # pulls Pillow in, and the missing-file path above stays dependency-free.
+ if not paths:
+ return []
from PIL import Image, ImageOps
images = []
for path in paths:
- # Checked explicitly so a bad path reports the PortOS-side cause rather
- # than Pillow's bare FileNotFoundError.
- if not Path(path).is_file():
- raise RuntimeError(f"Conditioning image is missing: {path}")
with Image.open(path) as handle:
image = handle.convert("RGB")
# In place: PortOS hands us ffmpeg-normalized PNGs with no orientation
diff --git a/scripts/generate_minimax_h3.test.js b/scripts/generate_minimax_h3.test.js
index e2c6f582a5..5f6efd16e1 100644
--- a/scripts/generate_minimax_h3.test.js
+++ b/scripts/generate_minimax_h3.test.js
@@ -114,9 +114,13 @@ describe('generate_minimax_h3.py', () => {
});
// Reading the keyframes happens before the ~83 GB load, so a bad path costs
- // a second rather than an hour.
- it('fails a missing conditioning image before any model load', () => {
+ // a second rather than an hour. Both branches asserted here run WITHOUT
+ // Pillow — CI's bare python3 has no PIL, and blocking `import PIL` on them
+ // would make a missing-file report (and every text-only run) need it.
+ it('fails a missing conditioning image without importing Pillow', () => {
const output = runPython(`${importRunner}\n${[
+ 'import sys',
+ 'sys.modules["PIL"] = None # make any `from PIL import ...` fail loudly',
'try:',
' runner.load_keyframes(["/nonexistent/first.png"])',
'except RuntimeError as exc:',
@@ -127,6 +131,31 @@ describe('generate_minimax_h3.py', () => {
expect(output).toMatch(/Conditioning image is missing/i);
});
+ it('skips the Pillow import entirely for a text-only run', () => {
+ const output = runPython(`${importRunner}\n${[
+ 'import sys',
+ 'sys.modules["PIL"] = None',
+ 'print(runner.load_keyframes([]))',
+ ].join('\n')}`);
+ expect(output.trim()).toBe('[]');
+ });
+
+ // A later keyframe's bad path must not cost a decode of the earlier one.
+ it('validates every keyframe path before opening any of them', () => {
+ const output = runPython(`${importRunner}\n${[
+ 'import sys, tempfile',
+ 'sys.modules["PIL"] = None',
+ 'with tempfile.NamedTemporaryFile(suffix=".png") as good:',
+ ' try:',
+ ' runner.load_keyframes([good.name, "/nonexistent/last.png"])',
+ ' except RuntimeError as exc:',
+ ' print(str(exc))',
+ ' else:',
+ ' raise SystemExit("missing second keyframe was accepted")',
+ ].join('\n')}`);
+ expect(output).toMatch(/Conditioning image is missing: \/nonexistent\/last\.png/);
+ });
+
it('emits the video_path JSON completion contract on stdout', () => {
const output = runPython(`${importRunner}\nrunner.emit_result(Path("/tmp/example.mp4"))`);
expect(JSON.parse(output)).toEqual({ video_path: '/tmp/example.mp4' });