[tune] Fixed save_to_dir w/ os.replace (#14510)

The method save_to_dir of the class Searcher in ray.tune.suggest.suggestion.py uses the os.rename method to replace tmp_search_ckpt to current ckpt. os.rename method will raise the [WinError 183] or file exists error of other operating system. os.replace is the currect way.
This commit is contained in:
EscapeReality846089495 2021-03-06 17:14:56 +08:00 committed by GitHub
parent 2395e25fc0
commit 33b271aa97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -265,7 +265,7 @@ class Searcher:
success = False
if success and os.path.exists(tmp_search_ckpt_path):
os.rename(
os.replace(
tmp_search_ckpt_path,
os.path.join(checkpoint_dir,
self.CKPT_FILE_TMPL.format(session_str)))