mirror of
https://github.com/wassname/ray.git
synced 2026-07-19 11:27:32 +08:00
[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:
committed by
Richard Liaw
co-authored by
Richard Liaw
parent
970cd78701
commit
5b40408678
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user