fix: fail-loud on node without time info; anchor test store path

This commit is contained in:
2026-07-15 22:16:39 -04:00
parent 05294412df
commit d6c595c4a4
2 changed files with 17 additions and 3 deletions
+6 -2
View File
@@ -30,7 +30,7 @@ def load_tree_nodes(store_dir: Path, video_id: str) -> dict[str, Any]:
异常:
FileNotFoundError: tree.json 不存在(沿用 factory.py fail-loud 先例)。
ValueError: 树无有效 roots、节点缺 id、或展平后 nodes 为空
ValueError: roots 非 list 或为空、节点缺 id、或节点既无 time_range 又无 timestamp
关键实现:
level 由遍历深度赋值(root=1/child=2/孙=3),不解析 node_id——node_id 累积式
@@ -54,7 +54,11 @@ def load_tree_nodes(store_dir: Path, video_id: str) -> dict[str, Any]:
time_range = node.get("time_range")
if time_range is None:
ts = node.get("timestamp")
time_range = [ts, ts] if ts is not None else [0, 0]
if ts is None:
raise ValueError(
f"节点既无 time_range 又无 timestamp(树损坏): {node_id} in {tree_path}"
)
time_range = [ts, ts]
nodes[node_id] = {
"card": node.get("card", {}),
"level": level,