Skip to content

Official Codebase of 3DCodeVerse

Python

flywheel: exporting from a battery dir reported "0 runs" as a success

gaoypengad9e537d82b6
diff --git a/harness/codeverse/flywheel/record.py b/harness/codeverse/flywheel/record.py
index 858f7a18..73ee2ac3 100644
--- a/harness/codeverse/flywheel/record.py
+++ b/harness/codeverse/flywheel/record.py
@@ -286,7 +286,15 @@ def iter_runs(
root = Path(runs_dir)
if not root.is_dir():
raise FileNotFoundError(f"runs dir not found: {root}")
- for d in sorted(p for p in root.iterdir() if p.is_dir()):
+ children = sorted(p for p in root.iterdir() if p.is_dir())
+ if not any((d / "record.json").is_file() for d in children) and (root / "runs").is_dir():
+ # pointing at a BATTERY dir (bench/out/<battery>) instead of its runs/ root is the
+ # easy mistake, and every exporter here reports "0 runs" as a success. Silence
+ # must not look like an empty dataset.
+ raise FileNotFoundError(
+ f"no run directories directly under {root} — did you mean {root / 'runs'}? "
+ f"(a battery directory holds its runs in runs/)")
+ for d in children:
if not (d / "record.json").is_file():
continue
ws = Workspace(d)
diff --git a/harness/tests/flywheel_cli/test_flywheel.py b/harness/tests/flywheel_cli/test_flywheel.py
index bd91c48e..c29e98bf 100644
--- a/harness/tests/flywheel_cli/test_flywheel.py
+++ b/harness/tests/flywheel_cli/test_flywheel.py
@@ -369,3 +369,29 @@ def test_export_includes_textured_assets_when_shipped(fake_run, tmp_path: Path):
export_samples(ws.root.parent, tmp_path / "ds2")
sdir2 = next((tmp_path / "ds2").rglob("meta.json")).parent
assert not (sdir2 / "textures").exists()
+
+
+def test_pointing_at_a_battery_dir_says_so_instead_of_exporting_nothing(tmp_path):
+ """`bench/out/<battery>` holds its runs in `runs/`, and pointing one level too high
+ used to report "runs 0, exported 0" as a SUCCESS — an empty dataset that looks like
+ a finished one. Silence must not read as an empty result."""
+ import pytest
+
+ from codeverse.flywheel.record import iter_runs
+
+ battery = tmp_path / "static_v2_flash"
+ (battery / "runs" / "some_run").mkdir(parents=True)
+ (battery / "runs" / "some_run" / "record.json").write_text("{}")
+
+ with pytest.raises(FileNotFoundError, match=r"did you mean .*runs"):
+ list(iter_runs(battery))
+
+
+def test_a_genuinely_empty_runs_root_is_still_just_empty(tmp_path):
+ """The hint only fires when a `runs/` sibling exists — an empty runs root is a
+ legitimate empty result, not an error."""
+ from codeverse.flywheel.record import iter_runs
+
+ empty = tmp_path / "runs"
+ empty.mkdir()
+ assert list(iter_runs(empty)) == []