Official Codebase of 3DCodeVerse
Python
dataset: a sample ships a textured GLB only when the pass started from ITS round's GLB
gaoypeng46f76d0cf418
diff --git a/harness/codeverse3d/addons/dataset/export.py b/harness/codeverse3d/addons/dataset/export.pyindex 37e2ccb6..9d2ce12c 100644--- a/harness/codeverse3d/addons/dataset/export.py+++ b/harness/codeverse3d/addons/dataset/export.py@@ -130,7 +130,7 @@ def export_one(raise S.SampleError(f"entry file {ENTRY_FILE[record.spec.language]} missing at {code_source}")renders = S.copy_renders(ws, rnd, dest)meshes = S.copy_link_meshes(ws, rnd, dest) if record.spec.language is Language.URDF_BLENDER else []- textured = S.copy_textured(ws, record, dest)+ textured = S.copy_textured(ws, record, rnd, dest)captions = load_captions(ws, record, captions_dir, slug=key)(dest / "captions.json").write_text(json.dumps(_caption_texts(captions), indent=2, ensure_ascii=False))all_files = sorted(written + renders + meshes + textured + ["captions.json", "meta.json"])diff --git a/harness/codeverse3d/addons/dataset/sample.py b/harness/codeverse3d/addons/dataset/sample.pyindex 1e74d816..686e9ac5 100644--- a/harness/codeverse3d/addons/dataset/sample.py+++ b/harness/codeverse3d/addons/dataset/sample.py@@ -38,7 +38,7 @@ from codeverse3d.contracts.common import ()from codeverse3d.contracts.run import RoundRecord, RunRecordfrom codeverse3d.record import _git-from codeverse3d.record.deliverable import deliverable_path, round_outputs+from codeverse3d.record.deliverable import deliverable_path, round_outputs, texture_shipped_forfrom codeverse3d.record.record import (effective_judgment,round_summary,@@ -231,11 +231,12 @@ def copy_renders(ws: Workspace, rnd: RoundRecord | None, dest: Path) -> list[strreturn out-def copy_textured(ws: Workspace, record: RunRecord, dest: Path) -> list[str]:- """When the texture pass shipped (``record.extra['texturing'].shipped``):- copy the generated ``textures/*.png`` and ``object_textured.glb`` into the sample."""+def copy_textured(ws: Workspace, record: RunRecord, rnd: RoundRecord | None, dest: Path) -> list[str]:+ """When a texture pass shipped from round ``rnd``'s own GLB (``texture_shipped_for``; a pack+ made for another round is not this sample's): copy the generated ``textures/*.png`` and+ ``object_textured.glb`` into the sample."""tex = record.extra.get("texturing") or {}- if not tex.get("shipped"):+ if not texture_shipped_for(ws, record, round_outputs(ws, rnd)):return []out: list[str] = []tex_dir = ws.root / str(tex.get("textures_dir") or "artifacts/textures")diff --git a/harness/codeverse3d/record/deliverable.py b/harness/codeverse3d/record/deliverable.pyindex f099c83f..5081d290 100644--- a/harness/codeverse3d/record/deliverable.py+++ b/harness/codeverse3d/record/deliverable.py@@ -180,6 +180,17 @@ def texture_report_for(ws: Workspace, glb: Path) -> dict | None:return rep+def texture_shipped_for(ws: Workspace, record: RunRecord, out: Path | None) -> bool:+ """Did a SHIPPED texture pass start from the round whose build outputs are ``out``+ (``round_outputs``)? Old layout (``out`` is ``artifacts/``): the one canonical pack+ belonged to the one round finalise rebuilt, so the record's flag answers."""+ if out is None:+ return False+ if out == ws.artifacts:+ return bool((record.extra.get("texturing") or {}).get("shipped"))+ return bool((texture_report_for(ws, out / "object.glb") or {}).get("shipped"))++def _copy_artifacts(ws: Workspace, record: RunRecord, rnd: RoundRecord | None, out: Path | None, w: _Writer) -> None:if out is None:return@@ -193,9 +204,7 @@ def _copy_artifacts(ws: Workspace, record: RunRecord, rnd: RoundRecord | None, osrc = ws.rebase(v.path)w.add_file(src, f"frames/{src.name}", "frames")tex = record.extra.get("texturing") or {}- # old layout: the one canonical pack belonged to the one round finalise rebuilt- shipped = tex.get("shipped") if out == ws.artifacts else (texture_report_for(ws, out / "object.glb") or {}).get("shipped")- if shipped:+ if texture_shipped_for(ws, record, out):w.add_file(ws.artifacts / "object_textured.glb", "object_textured.glb", "model")tex_dir = ws.root / str(tex.get("textures_dir") or "artifacts/textures")for p in sorted(tex_dir.glob("*.png")) if tex_dir.is_dir() else []:diff --git a/harness/tests/flywheel_cli/test_flywheel.py b/harness/tests/flywheel_cli/test_flywheel.pyindex 85e230ad..9cdbc348 100644--- a/harness/tests/flywheel_cli/test_flywheel.py+++ b/harness/tests/flywheel_cli/test_flywheel.py@@ -391,6 +391,7 @@ def test_export_graphics_sample(tmp_path: Path):def test_export_includes_textured_assets_when_shipped(fake_run, tmp_path: Path):+ from codeverse3d.texturing.run import report_pathfrom tests.flywheel_cli.conftest import tiny_pngws, rec = fake_run@@ -400,6 +401,8 @@ def test_export_includes_textured_assets_when_shipped(fake_run, tmp_path: Path):rec.extra["texturing"] = {"shipped": True, "glb_textured": "artifacts/object_textured.glb","textures_dir": "artifacts/textures"}ws.write_json(ws.record_path, rec)+ # the pass's report names the GLB it started from: the exported round's (r01, the pick)+ ws.write_json(report_path(ws), {**rec.extra["texturing"], "glb_in": "artifacts/r01/object.glb"})out = tmp_path / "ds"export_samples(ws.root.parent, out)sdir = next(out.rglob("meta.json")).parent@@ -410,6 +413,7 @@ def test_export_includes_textured_assets_when_shipped(fake_run, tmp_path: Path):# not shipped → nothing copiedrec.extra["texturing"]["shipped"] = Falsews.write_json(ws.record_path, rec)+ ws.write_json(report_path(ws), {**rec.extra["texturing"], "glb_in": "artifacts/r01/object.glb"})export_samples(ws.root.parent, tmp_path / "ds2")sdir2 = next((tmp_path / "ds2").rglob("meta.json")).parentassert not (sdir2 / "textures").exists()diff --git a/harness/tests/flywheel_cli/test_select.py b/harness/tests/flywheel_cli/test_select.pyindex 05eb57b2..91bb262c 100644--- a/harness/tests/flywheel_cli/test_select.py+++ b/harness/tests/flywheel_cli/test_select.py@@ -224,6 +224,25 @@ def test_package_textures_the_rounds_own_glb_once(tmp_path, monkeypatch):assert not (ws.deliverable / "object_textured.glb").exists()+def test_an_export_of_another_round_never_ships_the_pack_a_texture_pass_made_for_r02(tmp_path, monkeypatch):+ """copy_textured shipped whatever pack the record called shipped: texture r02, hand over r00+ (`pick --round 0`), export — and the r00 sample carried r02's textured GLB."""+ import codeverse3d.texturing.run as trun+ from codeverse3d.addons.dataset.export import export_one+ from codeverse3d.record.record import load_record++ ws = _run(tmp_path / "r", [(0.5, 0), (0.6, 0), (0.8, 0)])+ monkeypatch.setattr(trun, "texture_pass", _fake_texture_pass([]))+ select.package(ws.root, 2, texture=True)+ assert (ws.deliverable / "object_textured.glb").is_file()+ select.package(ws.root, 0)+ sample = export_one(ws, load_record(ws), tmp_path / "ds")+ assert "renders/object.glb" in sample.file_hashes and sample.meta.round == 0+ assert not any("textured" in f or f.startswith("textures/") for f in sample.file_hashes)+ select.package(ws.root, 2) # ... and the round it textured still ships it+ assert "renders/object_textured.glb" in export_one(ws, load_record(ws), tmp_path / "ds2").file_hashes++def test_a_failed_texture_pass_does_not_stop_the_hand_over(tmp_path, monkeypatch):import codeverse3d.texturing.run as trun