File size: 1,932 Bytes
e8055cf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | """Tests for harness/C/launch.py -- multi-GPU scene sharding across workers."""
from harness.C import launch
def test_launcher_imports():
assert callable(launch.main)
class _FakeRun:
rows = [{"id": 1}, {"id": 2}]
@staticmethod
def results_dir_for(*args, **kwargs):
return args[-1]
@classmethod
def load_questions(cls, scene=None):
return list(cls.rows)
def test_launch_skips_scene_already_fully_answered(tmp_path, capsys, monkeypatch):
scene = "scene-c"
monkeypatch.setattr(launch, "_load_run_module", lambda: _FakeRun)
scene_dir = tmp_path / scene
scene_dir.mkdir()
for row in _FakeRun.rows:
(scene_dir / f"{row['id']}.json").write_text("{}")
launch.launch(
"qwen3.5-2b", "explicit", "selective", 64, [scene], results_dir=tmp_path
)
output = capsys.readouterr().out
assert "skipped" in output
assert "DONE: 1 ok, 0 failed" in output
def test_launch_rebuild_forces_pending_even_when_answered(tmp_path, monkeypatch):
scene = "scene-c"
monkeypatch.setattr(launch, "_load_run_module", lambda: _FakeRun)
scene_dir = tmp_path / scene
scene_dir.mkdir()
for row in _FakeRun.rows:
(scene_dir / f"{row['id']}.json").write_text("{}")
monkeypatch.setattr(launch, "visible_gpus", lambda: [])
monkeypatch.setattr(
launch.mp,
"get_context",
lambda *_: (_ for _ in ()).throw(
RuntimeError("rebuild correctly reached worker dispatch")
),
)
try:
launch.launch(
"qwen3.5-2b",
"explicit",
"selective",
64,
[scene],
results_dir=tmp_path,
rebuild=True,
)
except RuntimeError as exc:
assert "rebuild correctly reached worker dispatch" in str(exc)
else:
raise AssertionError("expected rebuild to force scene into the pending path")
|