fix: backup before selfplay, never rmtree — crash-safe
rmtree(training_data) → mv to training_data_prev 训练成功后再清理backup, 崩了数据不丢
This commit is contained in:
@ -34,7 +34,11 @@ def run(cmd, cwd=HJHA_DIR, to=86400):
|
|||||||
def selfplay(games):
|
def selfplay(games):
|
||||||
log(f"── 自对弈 {games}局 ──")
|
log(f"── 自对弈 {games}局 ──")
|
||||||
td = os.path.join(HJHA_DIR, 'training_data')
|
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)
|
os.makedirs(td)
|
||||||
|
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
@ -293,6 +297,9 @@ def main():
|
|||||||
if not ok:
|
if not ok:
|
||||||
log("训练/eval失败! 跳过")
|
log("训练/eval失败! 跳过")
|
||||||
continue
|
continue
|
||||||
|
# 训练成功, 清理备份
|
||||||
|
backup = os.path.join(HJHA_DIR, 'training_data_prev')
|
||||||
|
if os.path.exists(backup): shutil.rmtree(backup)
|
||||||
if wr is not None:
|
if wr is not None:
|
||||||
winrate = wr
|
winrate = wr
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user