Official Codebase of 3DCodeVerse
Python
workspace: rendered_rounds() is the one 'which rounds have renders' scan — inspect, the texture pass and the gallery each globbed renders/r[0-9][0-9] themselves
gaoypengc98d24fc89f8
diff --git a/harness/codeverse3d/addons/gallery/index.py b/harness/codeverse3d/addons/gallery/index.pyindex caddcbbc..f294ec67 100644--- a/harness/codeverse3d/addons/gallery/index.py+++ b/harness/codeverse3d/addons/gallery/index.py@@ -124,8 +124,7 @@ def hero_view(ws: Workspace, rec: RunRecord, picked: int | None) -> tuple[str, sdef _articulation_sheet(ws: Workspace, picked: int | None) -> str:order = [picked] if picked is not None else []- order += [int(p.name[1:]) for p in sorted((ws.artifacts / "renders").glob("r[0-9][0-9]"), reverse=True)- if p.is_dir()]+ order += ws.rendered_rounds()[::-1]for idx in order:rel = f"artifacts/renders/r{idx:02d}/poses/articulation_sheet.png"if (ws.root / rel).is_file():diff --git a/harness/codeverse3d/cli/inspect_cmd.py b/harness/codeverse3d/cli/inspect_cmd.pyindex f5b44e37..6463fc56 100644--- a/harness/codeverse3d/cli/inspect_cmd.py+++ b/harness/codeverse3d/cli/inspect_cmd.py@@ -111,7 +111,7 @@ def judge(except RecordError as e:raise C.CliError(str(e), code=2) from epicked = select.pick(ws.root, record=rec) if round_index is None else None- idx = round_index if round_index is not None else (picked if picked is not None else _latest_round(ws))+ idx = round_index if round_index is not None else (picked if picked is not None else max(ws.rendered_rounds(), default=0))rnd = J.load_round(ws, rec, idx)if rnd is None or rnd.renders is None or not rnd.renders.views:raise C.CliError(f"round {idx} has no renders (rounds/r{idx:02d}.json / record.json)")@@ -207,7 +207,7 @@ def _render_round_or_refuse(ws, round_index: int | None) -> int:every round's own renders are already in ``artifacts/renders/rNN/``, and``3dcode pick <slug> --round N`` packages any round with its GLB."""- tree = _latest_round(ws)+ tree = max(ws.rendered_rounds(), default=0)if round_index is not None and round_index != tree:raise C.CliError(f"cannot render round {round_index}: `render` renders the working tree, which is at "@@ -218,13 +218,3 @@ def _render_round_or_refuse(ws, round_index: int | None) -> int:return tree-def _latest_round(ws) -> int:- rdir = ws.artifacts / "renders"- idxs = (- sorted(int(p.name[1:]) for p in rdir.glob("r[0-9][0-9]") if p.is_dir())- if rdir.is_dir()- else []- )- return idxs[-1] if idxs else 0--diff --git a/harness/codeverse3d/texturing/run.py b/harness/codeverse3d/texturing/run.pyindex 42a30351..2f052df2 100644--- a/harness/codeverse3d/texturing/run.py+++ b/harness/codeverse3d/texturing/run.py@@ -84,11 +84,8 @@ class TextureReport(BaseModel):def latest_sheet(ws: Workspace) -> Path | None:"""The most recent round's contact sheet (``artifacts/renders/rNN/sheet.png``)."""- rdir = ws.artifacts / "renders"- if not rdir.is_dir():- return None- rounds = sorted((p for p in rdir.glob("r[0-9][0-9]") if (p / "sheet.png").is_file()), key=lambda p: p.name)- return rounds[-1] / "sheet.png" if rounds else None+ sheets = (ws.renders_dir(i) / "sheet.png" for i in reversed(ws.rendered_rounds()))+ return next((p for p in sheets if p.is_file()), None)def _render_quick(glb: Path, out_dir: Path, views: Sequence[ViewPreset], render: Any | None) -> RenderSet:diff --git a/harness/codeverse3d/workspace.py b/harness/codeverse3d/workspace.pyindex 536d4d5d..60cf68b4 100644--- a/harness/codeverse3d/workspace.py+++ b/harness/codeverse3d/workspace.py@@ -212,6 +212,10 @@ class Workspace:def renders_dir(self, round_index: int) -> Path:return self.artifacts / "renders" / f"r{round_index:02d}"+ def rendered_rounds(self) -> list[int]:+ """The rounds that have a :meth:`renders_dir`, ascending."""+ return sorted(int(p.name[1:]) for p in (self.artifacts / "renders").glob("r[0-9][0-9]") if p.is_dir())+def gates_dir(self, round_index: int) -> Path:return self.artifacts / "gates" / f"r{round_index:02d}"