Skip to content

Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.

ci: --rife-only runs every test marked real_rife, the suite's one RIFE guard

Soohong Kim816fb7cdbb92
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8e331ef..f57f1c8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,11 @@
All notable public changes to `sprite-gen` are recorded here. Versions track the `version:` field in `SKILL.md` and `pyproject.toml`.
+## Unreleased
+
+- **Fix: the Linux lane's `--rife-only` runs every test of the real RIFE, not one file.** It ran `tests/video/test_rife.py` alone, while `--rife-unmeasured` skips every test that needs the real `rife-ncnn-vulkan` — so a real-RIFE test in another file (2.43.0's in `tests/video/test_crossfade.py` and `tests/video/test_ghost_screen.py`) was measured by neither run. Such a test now carries one mark, `real_rife` (registered in `pyproject.toml`): `tests/conftest.py` skips the marked tests where `rife.locate()` finds no RIFE, and `scripts/linux_lane.sh --rife-only` runs `pytest -m real_rife` over the whole suite, none skipped. A new real-RIFE test is run by `--rife-only` once it is marked. `docs/release.md` says what each run measures.
+- **`tests/release/test_lane_rife_collection.py`** collects the suite twice, once with a stand-in RIFE where `rife.locate()` looks (`SPRITE_GEN_RIFE`, `PATH`, the install root) and once with none: a test the two collections skip or collect differently and that is not marked `real_rife` fails it by name.
+
## v2.43.0 - No loop delivers a ghost frame unmeasured; a cross-fade inside one silhouette is named, not judged
- **Fix: no loop path delivers a ghost frame unmeasured — `video-cycle-align` takes a clean source frame beside it.** A video model filming a walk held on twos or threes sometimes leaves a frame half drawn between two drawings: a band of part coverage where a leg was and is going. The alignment took such a frame as filmed at its own time, never measured, and a frame RIFE made beside it carried the band and passed — `--between auto` judged a made frame only against its two neighbours (`dark_excess`, `outline_loss`), and a neighbour that is itself the ghost leaves nothing in excess. Now every frame delivered is read on its own coverage (`rife.ghost`: part-covered pixels, alpha 0.1–0.9, in regions at least 5 px thick, over the frame's solid pixels; a ghost over 0.3 %, `interpolation_quality.GHOST_WARN`). The source loop is screened first (`ghost_screen` per loop row and in `cycle_align`: `limit`, `thick_px`, the loop's own `level`, `reads`, and each filmed `ghosts` frame of `cycle.source/`); a loop whose median frame is over the limit is drawn part-covered (a glow, a translucent cape) and is not judged. Under `auto` and `nearest` a time on a filmed ghost takes the frame after it (or before it), a made frame that is a ghost gives way to the nearer source frame (fault `ghost`), and where that nearer frame is the ghost the other frame beside the time is taken; `rife` keeps both, named. Each such cell is listed in `ghost_at` (`at`, `source`, `ghost`, `taken`) with a warning line; a ghost with no clean frame beside it is kept and the line says to film the direction again. A loop already the set's length is screened the same way. Made frames in `smear` carry their `ghost` reading.
diff --git a/docs/release.md b/docs/release.md
index 38537c4..2e9dba0 100644
--- a/docs/release.md
+++ b/docs/release.md
@@ -17,6 +17,16 @@ GitHub-hosted CI(GitHub Actions)는 쓰지 않는다. 테스트 게이트와 whe
lavapipe 에서는 첫 업로드에서 죽는다 — 그래서 그런 호스트에서는 RIFE 를 떼어 내되 조용히 건너뛰지는
않는다.
+실제 rife-ncnn-vulkan 을 돌리는 시험은 `real_rife` 표시 하나로 가려진다(`pyproject.toml` 이 등록하고
+`tests/conftest.py` 가 RIFE 를 못 찾으면 그 표시가 붙은 시험을 건너뛴다). `--rife-unmeasured` 는
+RIFE 가 닿는 곳이 하나도 없는 상태로 스위트 전체를 돌려 그 시험들이 이 이유로 건너뛰어지고,
+`--rife-only` 는 `sprite-gen rife install`(그 확인 프레임)과 스위트 전체에서 `real_rife` 가 붙은
+시험(`pytest -m real_rife`)을 돌린다 — 하나라도 건너뛰거나, 표시된 시험이 없으면 실패다. 그래서 새
+실제-RIFE 시험은 표시만 붙이면 `--rife-only` 가 저절로 걷는다. 표시 없이 RIFE 유무에 따라 건너뛰거나
+모이는 시험이 생기면 두 실행 어느 쪽도 재지 않게 되므로, `tests/release/test_lane_rife_collection.py` 가
+스위트를 RIFE 가 있는 척하는 대역을 둔 채 한 번, 없는 채 한 번 모아 두 결과가 갈리는 시험마다 표시를
+요구하고, 없으면 그 시험의 이름을 대고 실패한다.
+
통과는 커밋 하나의 것이다. 어떤 커밋에서 잰 레인 — 한 번의 exit 0 이든, `--rife-only` 의 exit 0 이든 —
은 다른 커밋의 통과가 아니다. 이전 릴리즈나 부모 커밋의 통과를 다음 커밋으로 옮겨 적지 않고, 머지할
커밋과 태그 커밋을 각각 그 SHA 의 깨끗한 클론에서 잰다. `--rife-unmeasured` 로 잰 커밋은 같은 SHA 의
diff --git a/pyproject.toml b/pyproject.toml
index 1511c80..5c71acf 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -69,6 +69,11 @@ pythonpath = ["tests"]
# subprocess.wait(). 120s is generous for the extract/compose subprocess tests.
timeout = 120
timeout_method = "signal"
+# One mark names a test of the real rife-ncnn-vulkan: tests/conftest.py skips it where no RIFE is
+# reachable, and `scripts/linux_lane.sh --rife-only` runs exactly the marked tests (`-m real_rife`).
+markers = [
+ "real_rife: runs the real rife-ncnn-vulkan; skipped where none is reachable, run by `scripts/linux_lane.sh --rife-only`",
+]
# The pipeline ships an importable sprite_gen package. The canonical invocation is the
# console script declared above (`sprite-gen <tool>`); `scripts/<tool>.py` survives as a
diff --git a/scripts/linux_lane.sh b/scripts/linux_lane.sh
index 643ac69..8d112fb 100755
--- a/scripts/linux_lane.sh
+++ b/scripts/linux_lane.sh
@@ -24,10 +24,14 @@
# never passed over in silence:
# --rife-unmeasured "<why>" every gate but RIFE: no `rife install`, and the suite runs with an
# empty data directory and no RIFE on PATH, so the tests that need
-# the real binary skip for that stated reason. The run ends by naming
-# what it did not measure and exits 3, not 0.
+# the real binary (marked `real_rife`) skip for that stated reason. The
+# run ends by naming what it did not measure and exits 3, not 0.
# --rife-only the RIFE gates alone, on a host where Vulkan works: `rife install`
-# (its check frame) and tests/video/test_rife.py, none of it skipped.
+# (its check frame) and every test of the suite marked `real_rife`,
+# none of it skipped. The mark is the suite's only RIFE guard
+# (tests/conftest.py), so these are the tests `--rife-unmeasured`
+# skips for RIFE; tests/release/test_lane_rife_collection.py fails on
+# a test RIFE decides that is not marked.
# A commit has passed the lane when one run exits 0, or when a `--rife-unmeasured` run (exit 3)
# and a `--rife-only` run (exit 0) of the same commit both did.
set -euo pipefail
@@ -114,10 +118,11 @@ step "install (clean environment, as the quickstart does)"
if [ "$rife_only" = 1 ]; then
step "RIFE (sprite-gen rife install)"
.venv/bin/sprite-gen rife install
- step "RIFE tests (tests/video/test_rife.py, none skipped)"
+ step "RIFE tests (every test marked real_rife, none skipped)"
rife_log=$(mktemp)
trap 'rm -f "$rife_log"' EXIT
- .venv/bin/python -m pytest -q -rs tests/video/test_rife.py | tee "$rife_log"
+ # No test marked: pytest exits 5 ("no tests ran"), and the lane with it.
+ .venv/bin/python -m pytest -q -rs -m real_rife | tee "$rife_log"
! grep -E '^SKIPPED' "$rife_log" >/dev/null || fail "a RIFE test skipped; this run is meant to measure them"
echo "linux_lane: the RIFE gates passed at $sha"
exit 0
diff --git a/tests/conftest.py b/tests/conftest.py
index 822e103..eeebc94 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -41,6 +41,22 @@ def run_script(name: str, *args: str) -> subprocess.CompletedProcess[str]:
)
+def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
+ """A test marked `real_rife` runs the real binary: skipped where `rife.locate()` finds none. The
+ mark is the only RIFE guard, so the tests it skips are the tests `scripts/linux_lane.sh
+ --rife-only` runs (`-m real_rife`); tests/release/test_lane_rife_collection.py holds the suite to it."""
+ marked = [item for item in items if item.get_closest_marker("real_rife")]
+ if not marked:
+ return
+ from sprite_gen.video import rife
+
+ try:
+ rife.locate()
+ except rife.RifeUnavailable:
+ for item in marked:
+ item.add_marker(pytest.mark.skip(reason="rife-ncnn-vulkan not installed (SPRITE_GEN_RIFE / PATH / sprite-gen rife install)"))
+
+
@pytest.fixture
def fixture_run_dir(tmp_path: Path) -> Path:
"""A throwaway copy of the golden fixture run dir."""
diff --git a/tests/release/test_lane_rife_collection.py b/tests/release/test_lane_rife_collection.py
new file mode 100644
index 0000000..2c760b9
--- /dev/null
+++ b/tests/release/test_lane_rife_collection.py
@@ -0,0 +1,96 @@
+# SPDX-License-Identifier: Apache-2.0
+"""`scripts/linux_lane.sh --rife-unmeasured` runs the suite where no RIFE is reachable, and the tests
+that need one skip; `--rife-only` runs the tests marked `real_rife` (`pytest -m real_rife`), none
+skipped. A test that skips without RIFE and is not marked is measured by neither run.
+
+The suite is collected twice, with nothing else changed: once with a stand-in RIFE everywhere
+`rife.locate()` looks (SPRITE_GEN_RIFE, PATH, the install root) and once with none. Every test the
+two collections skip, or collect, differently is decided by RIFE, and must carry the mark."""
+
+from __future__ import annotations
+
+import json
+import os
+import shutil
+import subprocess
+import sys
+from pathlib import Path
+
+from sprite_gen.video import rife
+
+ROOT = Path(__file__).resolve().parents[2]
+
+# Loaded into each collection (-p): per collected test, whether its skip and skipif marks skip it —
+# pytest's own reading, the mark tests/conftest.py adds included — and whether it is marked real_rife.
+PROBE = '''
+import json, os
+from _pytest.skipping import evaluate_skip_marks
+
+
+def pytest_collection_finish(session):
+ with open(os.environ["RIFE_PROBE_OUT"], "w") as out:
+ json.dump({item.nodeid: [evaluate_skip_marks(item) is not None, item.get_closest_marker("real_rife") is not None]
+ for item in session.items}, out)
+'''
+
+
+def _without_rife(path: str, shadow: Path) -> str:
+ """PATH with each directory that holds RIFE swapped for links to everything else in it."""
+ dirs = []
+ for i, d in enumerate(path.split(os.pathsep)):
+ found = shutil.which(rife.BINARY, path=d) if d else None
+ if found:
+ d = shadow / str(i)
+ d.mkdir(parents=True)
+ for entry in Path(found).parent.iterdir():
+ if entry.name != Path(found).name:
+ (d / entry.name).symlink_to(entry)
+ dirs.append(str(d))
+ return os.pathsep.join(dirs)
+
+
+def _stand_in(data: Path) -> Path:
+ """An executable named as RIFE, with its model beside it, at the install root under `data`: what
+ `rife.locate()` checks. Never run — the collections run no test."""
+ binary = rife.installed_binary(data / "rife")
+ (binary.parent / rife.MODEL).mkdir(parents=True)
+ for name in ("flownet.param", "flownet.bin"):
+ (binary.parent / rife.MODEL / name).write_bytes(b"")
+ binary.write_text("#!/bin/sh\nexit 1\n")
+ binary.chmod(0o755)
+ return binary
+
+
+def _collect(tmp_path: Path, name: str, env: dict[str, str]) -> dict[str, list[bool]]:
+ out = tmp_path / f"{name}.json"
+ proc = subprocess.run(
+ [sys.executable, "-m", "pytest", "--collect-only", "-qq", "-p", "rife_probe", "-p", "no:cacheprovider"],
+ cwd=ROOT,
+ env={**env, "RIFE_PROBE_OUT": str(out)},
+ capture_output=True,
+ text=True,
+ )
+ assert proc.returncode == 0, f"collection with {name} failed:\n{proc.stdout[-3000:]}\n{proc.stderr[-3000:]}"
+ return json.loads(out.read_text())
+
+
+def test_every_test_rife_decides_is_marked_real_rife(tmp_path):
+ (tmp_path / "rife_probe.py").write_text(PROBE)
+ # The whole suite, as the lane collects it: no PYTEST_ADDOPTS selecting a part.
+ base = {k: v for k, v in os.environ.items() if k not in ("SPRITE_GEN_RIFE", "SPRITE_GEN_RIFE_MODEL", "PYTEST_ADDOPTS")}
+ base["PYTHONPATH"] = os.pathsep.join(filter(None, [str(tmp_path), base.get("PYTHONPATH")]))
+ base["PATH"] = _without_rife(base.get("PATH", ""), tmp_path / "path")
+ stand_in = _stand_in(tmp_path / "with")
+ absent = _collect(tmp_path, "no RIFE", {**base, "SPRITE_GEN_DATA_DIR": str(tmp_path / "without")})
+ present = _collect(tmp_path, "a stand-in RIFE", {
+ **base,
+ "SPRITE_GEN_DATA_DIR": str(tmp_path / "with"),
+ "SPRITE_GEN_RIFE": str(stand_in),
+ "PATH": os.pathsep.join([str(stand_in.parent), base["PATH"]]),
+ })
+ decided = (present.keys() ^ absent.keys()) | {n for n in present.keys() & absent.keys() if present[n][0] != absent[n][0]}
+ unmarked = sorted(n for n in decided if not (present.get(n) or absent[n])[1])
+ assert not unmarked, (
+ "skipped or collected by whether RIFE is reachable, but not marked real_rife — "
+ "`scripts/linux_lane.sh --rife-only` would not run them:\n" + "\n".join(unmarked))
+ assert decided, "no test is decided by RIFE: the stand-in or the conftest skip no longer reaches the marked tests"
diff --git a/tests/video/test_crossfade.py b/tests/video/test_crossfade.py
index 2734abd..133de30 100644
--- a/tests/video/test_crossfade.py
+++ b/tests/video/test_crossfade.py
@@ -25,7 +25,6 @@ from PIL import Image, ImageDraw
from sprite_gen.video import align, repair, rife
from sprite_gen.video.interpolation_quality import CROSSFADE_LOOK, faults, looks
from tests.video.test_ghost_screen import _band, _block_walker, _cut
-from tests.video.test_rife import _real_rife_available
GREY, BLACK = (125, 118, 112), (20, 20, 20)
LIGHT_BOOTS = (225, 210, 180)
@@ -180,7 +179,7 @@ def test_jump_repair_takes_a_crossfaded_proposal_and_names_it(monkeypatch):
assert first["proposal"]["crossfade"] > CROSSFADE_LOOK and out[1] is made
[email protected](not _real_rife_available(), reason="rife-ncnn-vulkan not installed (SPRITE_GEN_RIFE / PATH / sprite-gen rife install)")
def test_real_rife_through_a_short_step_reads_no_crossfade():
"""A short step the flow follows: RIFE's frames are softer than their sources, never a cross-fade."""
interpolate = rife.Rife()
diff --git a/tests/video/test_ghost_screen.py b/tests/video/test_ghost_screen.py
index 458ca1b..e6aca55 100644
--- a/tests/video/test_ghost_screen.py
+++ b/tests/video/test_ghost_screen.py
@@ -23,7 +23,7 @@ from sprite_gen.video import loop as loop_mod
from sprite_gen.video import repair
from sprite_gen.video.interpolation_quality import GHOST_WARN, faults, ghost_screen
from tests.video.test_cycle_align import _walker as _block_walker
-from tests.video.test_rife import _real_rife_available, _walker
+from tests.video.test_rife import _walker
def _band(im: Image.Image, *, alpha: float = 0.3, box=(0.36, 0.78, 0.64, 0.99)) -> Image.Image:
@@ -197,7 +197,7 @@ def test_jump_repair_rejects_a_proposal_that_carries_a_ghost(monkeypatch):
assert [f.tobytes() for f in out] == before
[email protected](not _real_rife_available(), reason="rife-ncnn-vulkan not installed (SPRITE_GEN_RIFE / PATH / sprite-gen rife install)")
def test_real_rife_delivers_no_cell_carrying_a_filmed_ghost():
"""A filmed ghost resampled 4 to 8 through the real RIFE: before the screen the ghost itself was
taken at its own time, unmeasured, and the frames made beside it carried it, judged only beyond it."""
diff --git a/tests/video/test_rife.py b/tests/video/test_rife.py
index bdb1c36..45e5a59 100644
--- a/tests/video/test_rife.py
+++ b/tests/video/test_rife.py
@@ -2,8 +2,8 @@
"""RIFE runner: it is found or refused by name, and a real binary (when one is installed)
interpolates an RGBA frame that sits between its two neighbours, alpha included.
-The real-binary test runs only where `rife-ncnn-vulkan` is reachable (SPRITE_GEN_RIFE, PATH or the install root);
-the locating rules need no binary at all."""
+The real-binary tests are marked `real_rife` and run only where `rife-ncnn-vulkan` is reachable (SPRITE_GEN_RIFE,
+PATH or the install root; tests/conftest.py); the locating rules need no binary at all."""
from __future__ import annotations
@@ -98,15 +98,7 @@ def _disc(cx: int) -> Image.Image:
return Image.fromarray(im, "RGBA")
-def _real_rife_available() -> bool:
- try:
- rife.locate()
- except rife.RifeUnavailable:
- return False
- return True
-
-
[email protected](not _real_rife_available(), reason="rife-ncnn-vulkan not installed (SPRITE_GEN_RIFE / PATH / sprite-gen rife install)")
def test_real_rife_makes_the_frame_between_in_colour_and_alpha():
interpolate = rife.Rife()
mid = interpolate(_disc(40), _disc(72), 0.5)
@@ -119,7 +111,7 @@ def test_real_rife_makes_the_frame_between_in_colour_and_alpha():
assert interpolate.made == 1
[email protected](not _real_rife_available(), reason="rife-ncnn-vulkan not installed (SPRITE_GEN_RIFE / PATH / sprite-gen rife install)")
def test_real_rife_between_crossing_legs_adds_no_black():
"""Two outlined legs walk through each other (the near one forward, the far one back): the frame
between must not be darker inside the body than either neighbour. 2.24 premultiplied the colour
@@ -210,7 +202,7 @@ def test_outline_loss_reads_a_melted_limb_and_not_a_moved_one():
assert rife.smear(flat[2], flat[0], flat[1])["outline_loss"] <= 0.01
[email protected](not _real_rife_available(), reason="rife-ncnn-vulkan not installed (SPRITE_GEN_RIFE / PATH / sprite-gen rife install)")
def test_real_rife_melts_legs_crossing_too_far_and_alignment_takes_the_nearer_frame_there():
"""Outlined legs that cross a long way between two drawings (a clip drawn on twos) come out of
RIFE as one shape with no outline where they meet the air (measured 32 % of the edge at t=0.5);
@@ -237,7 +229,7 @@ def test_real_rife_melts_legs_crossing_too_far_and_alignment_takes_the_nearer_fr
assert facts["made_at"] == [1, 3] and facts["nearest_at"] == [] and all(not m["faults"] for m in facts["smear"])
[email protected](not _real_rife_available(), reason="rife-ncnn-vulkan not installed (SPRITE_GEN_RIFE / PATH / sprite-gen rife install)")
def test_real_rife_repair_rejects_outline_loss_and_keeps_the_original_middle(monkeypatch):
from sprite_gen.video import repair