Skip to content

Commit

Permalink
[tune] Overwrite files on restore (replace instead of rename) (#28404)
Browse files Browse the repository at this point in the history
Windows complains when files already exist on restore, so we should replace instead.

Signed-off-by: Kai Fricke <[email protected]>
  • Loading branch information
krfricke authored Sep 9, 2022
1 parent 9a5540b commit 95cbe52
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/ray/tune/impl/tuner_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions python/ray/tune/tests/test_tuner_restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 95cbe52

Please sign in to comment.