Official Codebase of 3DCodeVerse
Python
reference: the image-model factory is public get_image_model — the scene track and the texture CLI imported a private name, and the CLI kept a second wrapper as its own test seam
gaoypengd2b6ee6d551c
diff --git a/harness/codeverse3d/cli/texture_cmd.py b/harness/codeverse3d/cli/texture_cmd.pyindex f80e3d78..850f47ce 100644--- a/harness/codeverse3d/cli/texture_cmd.py+++ b/harness/codeverse3d/cli/texture_cmd.py@@ -22,12 +22,6 @@ texture_app = typer.Typer(name="texture", help="Text-to-image texturing: objectRunsDirOpt = C.RunsDirOpt-def _image_model(name: str | None):- from codeverse3d import reference-- return reference._image_model(name or "")--@texture_app.command("pass")def pass_(slug: str,@@ -39,6 +33,7 @@ def pass_(runs_dir: RunsDirOpt = None,) -> None:"""Texture the picked round's object.glb (``addons.select``) → artifacts/object_textured.glb (+ textures/)."""+ from codeverse3d import referencefrom codeverse3d.addons import selectfrom codeverse3d.cost.instrument import run_ledgerfrom codeverse3d.record.record import RecordError, load_record@@ -65,7 +60,7 @@ def pass_(with (C.mutating(ws, what=f"3dcode texture pass {ws.root.name}", action="texture"),run_ledger(ws.root, run=ws.root.name, create=False)):rep = texture_pass(ws, spec, plan, model_id=model or spec.backends.planner,- image_model=_image_model(image_model), judge=judge,+ image_model=reference.get_image_model(image_model or ""), judge=judge,judge_model_id=judge_model, size=size, glb_in=glb, sheet=sheet)_print_report(rep, ws)@@ -114,6 +109,7 @@ def scene_pack(runs_dir: RunsDirOpt = None,) -> None:"""Generate the scene's tileable texture pack into public/textures/ (+ manifest.json)."""+ from codeverse3d import referencefrom codeverse3d.cost.instrument import run_ledgerfrom codeverse3d.spatial.tool_common import load_planfrom codeverse3d.texturing.plan import scene_texture_pack, texture_pack_prompt@@ -128,7 +124,7 @@ def scene_pack(# like `pass`: the pack's plan + image spend joins the run's ledger when it has onewith (C.mutating(ws, what=f"3dcode texture scene-pack {ws.root.name}", action="texture"),run_ledger(ws.root, run=ws.root.name, create=False)):- pack = scene_texture_pack(plan, out or ws.public / "textures", _image_model(image_model), model_id, size=size, n_max=n)+ pack = scene_texture_pack(plan, out or ws.public / "textures", reference.get_image_model(image_model or ""), model_id, size=size, n_max=n)rows = {name: f"{e.file or 'FAILED'} tile={e.tile_size_m:.2f}m {e.material_family}/{e.role} seam={e.seam_score:.3f}"+ (f" {e.error}" if e.error else "") for name, e in pack.entries.items()}console.print(kv_table("scene texture pack", rows))diff --git a/harness/codeverse3d/reference.py b/harness/codeverse3d/reference.pyindex 7ebd0f83..b721e29d 100644--- a/harness/codeverse3d/reference.py+++ b/harness/codeverse3d/reference.py@@ -869,7 +869,7 @@ def ground_spec(return spec, empty, whytry:model = model if model is not None else _chat_model(spec.backends.planner)- image_model = image_model if image_model is not None else _image_model(image_model_id)+ image_model = image_model if image_model is not None else get_image_model(image_model_id)except Exception as e: # noqa: BLE001 — no keys / no package → run without a referencewhy = f"reference grounding unavailable: {type(e).__name__}: {e}"log.warning("%s", why)@@ -895,7 +895,7 @@ def _chat_model(model_id: str) -> Any:return get_chat_model(model_id)-def _image_model(model_id: str = "") -> Any:+def get_image_model(model_id: str = "") -> Any:from codeverse3d.models.gemini import DEFAULT_IMAGE_MODEL, GeminiImageModelreturn GeminiImageModel(model_id or DEFAULT_IMAGE_MODEL)diff --git a/harness/codeverse3d/tracks/scene.py b/harness/codeverse3d/tracks/scene.pyindex 0a2dbddc..27b5ab8b 100644--- a/harness/codeverse3d/tracks/scene.py+++ b/harness/codeverse3d/tracks/scene.py@@ -281,12 +281,12 @@ class SceneTrack(BaseTrack):Runs BEFORE env / zones, because its whole point is that those prompts can namethe files. Advisory: a pack that cannot be generated leaves the run exactly as itwas before this stage existed (an empty manifest renders no prompt block)."""- from codeverse3d.reference import _image_model+ from codeverse3d.reference import get_image_modelfrom codeverse3d.texturing.plan import scene_texture_packplan: ScenePlan = ctx.plan # type: ignore[assignment]try:- pack = scene_texture_pack(plan, ctx.ws.public / "textures", _image_model(""),+ pack = scene_texture_pack(plan, ctx.ws.public / "textures", get_image_model(),ctx.spec.backends.planner, cache_dir=ctx.settings.cache_dir / "textures")except Exception as e: # noqa: BLE001 — textures accelerate, they must never kill a runctx.events.emit("textures.stage_failed", error=f"{type(e).__name__}: {e}"[:300])diff --git a/harness/tests/flywheel_cli/test_select.py b/harness/tests/flywheel_cli/test_select.pyindex 7b038608..3779d73d 100644--- a/harness/tests/flywheel_cli/test_select.py+++ b/harness/tests/flywheel_cli/test_select.py@@ -303,7 +303,7 @@ def test_cli_texture_pass_textures_the_picked_round_not_the_last_build(tmp_path:seen: dict = {}monkeypatch.setattr("codeverse3d.texturing.run.texture_pass", lambda *a, **kw: seen.update(kw))monkeypatch.setattr("codeverse3d.cli.texture_cmd._print_report", lambda rep, ws: None)- monkeypatch.setattr("codeverse3d.cli.texture_cmd._image_model", lambda name: None)+ monkeypatch.setattr("codeverse3d.reference.get_image_model", lambda name: None)monkeypatch.setattr("codeverse3d.spatial.tool_common.load_plan", lambda path: None)r = runner.invoke(app, ["texture", "pass", "chair", "--runs-dir", str(tmp_path / "runs"), "--no-judge"])assert r.exit_code == 0, r.outputdiff --git a/harness/tests/prompts/manifest.py b/harness/tests/prompts/manifest.pyindex 89dd9547..45ca4be0 100644--- a/harness/tests/prompts/manifest.py+++ b/harness/tests/prompts/manifest.py@@ -376,7 +376,7 @@ def _switch(name: str, value: str) -> None:def _scene_textures(rig: Rig) -> None:_switch("C3D_SCENE_TEXTURES", "on")- with mock.patch("codeverse3d.texturing.plan.scene_texture_pack", _textures), mock.patch("codeverse3d.reference._image_model"):+ with mock.patch("codeverse3d.texturing.plan.scene_texture_pack", _textures), mock.patch("codeverse3d.reference.get_image_model"):rig.run(rounds=0)rig.run(rounds=1, resume=True)diff --git a/harness/tests/texturing/test_tools_cli.py b/harness/tests/texturing/test_tools_cli.pyindex 5e0c0579..b683eacc 100644--- a/harness/tests/texturing/test_tools_cli.py+++ b/harness/tests/texturing/test_tools_cli.py@@ -73,7 +73,7 @@ def test_cli_scene_pack_spend_joins_the_runs_ledger(tmp_path, chair_spec, monkeyreturn ScenePack(out_dir=str(out_dir))monkeypatch.setattr("codeverse3d.texturing.plan.scene_texture_pack", fake_pack)- monkeypatch.setattr("codeverse3d.cli.texture_cmd._image_model", lambda name: FakeImageModel())+ monkeypatch.setattr("codeverse3d.reference.get_image_model", lambda name: FakeImageModel())res = CliRunner().invoke(app, ["texture", "scene-pack", str(ws.root), "--model", ""])assert res.exit_code == 0, res.outputassert [r.label for r in load_ledger(ws.root)] == ["planner", "texture_pack"]