From 33b271aa97acc716d201ccc68fe75d5587b1e0c9 Mon Sep 17 00:00:00 2001 From: EscapeReality846089495 <846089495@qq.com> Date: Sat, 6 Mar 2021 17:14:56 +0800 Subject: [PATCH] [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. --- python/ray/tune/suggest/suggestion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/ray/tune/suggest/suggestion.py b/python/ray/tune/suggest/suggestion.py index 3612576d4..4dd37b73c 100644 --- a/python/ray/tune/suggest/suggestion.py +++ b/python/ray/tune/suggest/suggestion.py @@ -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)))