fix: fail-loud on node without time info; anchor test store path
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user