From aa4cbd0a3eba2ed15dbefa99cbc40959ae7f6524 Mon Sep 17 00:00:00 2001 From: xiaoou Date: Mon, 13 Jul 2026 11:51:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20backup=20before=20selfplay,=20never=20rm?= =?UTF-8?q?tree=20=E2=80=94=20crash-safe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rmtree(training_data) → mv to training_data_prev 训练成功后再清理backup, 崩了数据不丢 --- scripts/training_orchestrator.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/training_orchestrator.py b/scripts/training_orchestrator.py index d7b89ecd..f8d831c8 100644 --- a/scripts/training_orchestrator.py +++ b/scripts/training_orchestrator.py @@ -34,7 +34,11 @@ def run(cmd, cwd=HJHA_DIR, to=86400): def selfplay(games): log(f"── 自对弈 {games}局 ──") td = os.path.join(HJHA_DIR, 'training_data') - if os.path.exists(td): shutil.rmtree(td) + # 先备份旧数据, 崩了也不丢 + if os.path.exists(td): + backup = f"{td}_prev" + if os.path.exists(backup): shutil.rmtree(backup) + shutil.move(td, backup) os.makedirs(td) env = os.environ.copy() @@ -293,6 +297,9 @@ def main(): if not ok: log("训练/eval失败! 跳过") continue + # 训练成功, 清理备份 + backup = os.path.join(HJHA_DIR, 'training_data_prev') + if os.path.exists(backup): shutil.rmtree(backup) if wr is not None: winrate = wr