diff --git a/python/ray/tune/impl/tuner_internal.py b/python/ray/tune/impl/tuner_internal.py index 6080e48b76d1..0c5cb15eb48a 100644 --- a/python/ray/tune/impl/tuner_internal.py +++ b/python/ray/tune/impl/tuner_internal.py @@ -215,7 +215,7 @@ def _restore_from_path_or_uri( self._setup_create_experiment_checkpoint_dir(self._run_config) ) for file_dir in experiment_checkpoint_path.glob("*"): - file_dir.rename(new_exp_path / file_dir.name) + file_dir.replace(new_exp_path / file_dir.name) shutil.rmtree(experiment_checkpoint_path) self._experiment_checkpoint_dir = str(new_exp_path) diff --git a/python/ray/tune/tests/test_tuner_restore.py b/python/ray/tune/tests/test_tuner_restore.py index 108331b650e4..8741a42cfdbd 100644 --- a/python/ray/tune/tests/test_tuner_restore.py +++ b/python/ray/tune/tests/test_tuner_restore.py @@ -347,6 +347,10 @@ def test_tuner_restore_from_cloud(ray_start_2_cpus, tmpdir): # Contents changed assert prev_lstat.st_size != after_lstat.st_size + # Overwriting should work + tuner3 = Tuner.restore("memory:///test/restore/exp_dir") + tuner3.fit() + if __name__ == "__main__": import sys