Skip to content

Commit 521d9d4

Browse files
committed
fix(ci): add imageio runtime dep, narrow types for ty
- pyproject: `imageio[ffmpeg]>=2.20` is now a runtime dep so the shared `EpisodeVideoRecorder` works on a base install (and CI's bare `uv sync --all-extras --dev` env can run the recorder tests). - recording.py: rewrite `_resolve_filename` with `isinstance(spec, str)` branches so ty can narrow `str | Callable[..., str]` at the call site. - test_recording.py: add `assert final is not None` before `.exists()` in three tests so ty narrows `Path | None`. Replace `r.count_frames()` with iteration-based counting (imageio's `_BaseReaderWriter` stub omits `count_frames`) and `# ty: ignore[not-iterable]` for the same stub gap on `__iter__`. - benchmark.py: drop unused `# type: ignore` on `mani_skill.envs.sapien_env` import (ty flagged it as unused after the runtime-dep refresh).
1 parent 1e0e77d commit 521d9d4

4 files changed

Lines changed: 12 additions & 5 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ license = {text = "Apache-2.0"}
1212
dependencies = [
1313
"anyio>=4.0.0",
1414
"filelock>=3.0",
15+
"imageio[ffmpeg]>=2.20", # Streaming mp4 writer for benchmarks/recording.py
1516
"lazyregistry>=0.4.0", # Python 3.8 support
1617
"msgpack>=1.0.0",
1718
"numpy>=1.24",

src/vla_eval/benchmarks/recording.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,10 @@ def discard(self) -> None:
278278
_safe_unlink(tempfile_path)
279279

280280
def _resolve_filename(self, context: Mapping[str, Any]) -> str:
281-
if callable(self._filename_spec):
282-
return self._filename_spec(context)
283-
return self._filename_spec.format(**context)
281+
spec = self._filename_spec
282+
if isinstance(spec, str):
283+
return spec.format(**context)
284+
return spec(context)
284285

285286

286287
def _safe_unlink(path: Path | None) -> None:

src/vla_eval/benchmarks/robomme/benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def _patched_parse(sim_backend, render_backend):
342342

343343
_backend_mod.parse_sim_and_render_backend = _patched_parse
344344

345-
import mani_skill.envs.sapien_env # type: ignore
345+
import mani_skill.envs.sapien_env
346346

347347
mani_skill.envs.sapien_env.parse_sim_and_render_backend = _patched_parse
348348
except Exception as e:

tests/test_recording.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ def _frame() -> np.ndarray:
2929

3030

3131
def _count_frames(path: Path) -> int:
32+
# imageio's `_BaseReaderWriter` type stub omits __iter__; the concrete
33+
# Reader returned for mp4 is iterable in practice.
3234
import imageio
3335

3436
with imageio.get_reader(str(path)) as r:
35-
return r.count_frames()
37+
return sum(1 for _ in r) # ty: ignore[not-iterable]
3638

3739

3840
# ---------------------------------------------------------------------------
@@ -58,6 +60,7 @@ def test_save_uses_status_in_filename(tmp_path: Path) -> None:
5860
rec.start({"task_name": "T", "episode_idx": 7})
5961
rec.record(_frame())
6062
final = rec.save(status="fail")
63+
assert final is not None
6164
assert final == tmp_path / "T_ep7_fail.mp4"
6265
assert final.exists()
6366

@@ -78,6 +81,7 @@ def test_consecutive_episodes_each_produce_their_own_file(tmp_path: Path) -> Non
7881
rec.record(_frame())
7982
rec.record(_frame())
8083
final = rec.save(status="success")
84+
assert final is not None
8185
assert final == tmp_path / f"T_ep{ep}_success.mp4"
8286
assert final.exists()
8387
assert sorted(p.name for p in tmp_path.glob("T_ep*.mp4")) == [
@@ -101,6 +105,7 @@ def test_filename_template_with_subdirectories(tmp_path: Path) -> None:
101105
rec.start({"suite": "Counting", "task_name": "PickX", "episode_idx": 12})
102106
rec.record(_frame())
103107
final = rec.save(status="success")
108+
assert final is not None
104109
assert final == tmp_path / "Counting" / "PickX_ep0012_success.mp4"
105110
assert final.exists()
106111

0 commit comments

Comments
 (0)