[tune] Remove py2.7-specific code (#6665)

* Remove backwards compatability py2.7 code.

* Use exists_ok=True in ray

* nit

* nit

Co-authored-by: Richard Liaw <rliaw@berkeley.edu>
This commit is contained in:
Ujval Misra
2020-01-03 01:03:13 -08:00
committed by Richard Liaw
co-authored by Richard Liaw
parent 970cd78701
commit 5b40408678
9 changed files with 18 additions and 52 deletions
+3 -6
View File
@@ -74,8 +74,7 @@ class TrainableUtil:
@staticmethod
def make_checkpoint_dir(checkpoint_dir):
"""Creates a checkpoint directory at the provided path."""
if not os.path.exists(checkpoint_dir):
os.makedirs(checkpoint_dir)
os.makedirs(checkpoint_dir, exist_ok=True)
# Drop marker in directory to identify it as a checkpoint dir.
open(os.path.join(checkpoint_dir, ".is_checkpoint"), "a").close()
@@ -127,8 +126,7 @@ class Trainable:
self._logdir = self._result_logger.logdir
else:
logdir_prefix = datetime.today().strftime("%Y-%m-%d_%H-%M-%S")
ray.utils.try_to_create_directory(
DEFAULT_RESULTS_DIR, warn_if_exist=False)
ray.utils.try_to_create_directory(DEFAULT_RESULTS_DIR)
self._logdir = tempfile.mkdtemp(
prefix=logdir_prefix, dir=DEFAULT_RESULTS_DIR)
self._result_logger = UnifiedLogger(
@@ -411,8 +409,7 @@ class Trainable:
path = os.path.join(tmpdir, relpath_name)
# This may be a subdirectory, hence not just using tmpdir
if not os.path.exists(os.path.dirname(path)):
os.makedirs(os.path.dirname(path))
os.makedirs(os.path.dirname(path), exist_ok=True)
with open(path, "wb") as f:
f.write(file_contents)