robustness: _dump_json 自建父目录(修 R3 覆盖目录写入失败静默失效);新增端到端 wrapper 测试 12 项
This commit is contained in:
@@ -81,7 +81,15 @@ def _load_json(path):
|
||||
|
||||
|
||||
def _dump_json(obj, path):
|
||||
"""写 JSON 到覆盖目录;失败返回 False。
|
||||
|
||||
自己负责把父目录建出来(不依赖调用方先前建过)——10-03 端到端测试出现过
|
||||
"覆盖目录建了但 tokenizer 子目录写不进去"导致 R3 静默失效,这里做成自洽。
|
||||
"""
|
||||
try:
|
||||
parent = os.path.dirname(os.path.abspath(path))
|
||||
if parent:
|
||||
os.makedirs(parent, exist_ok=True)
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
json.dump(obj, f, ensure_ascii=False, indent=1)
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user