[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 04:03:13 -05:00
committed by Richard Liaw
parent 970cd78701
commit 5b40408678
9 changed files with 18 additions and 52 deletions
+2 -14
View File
@@ -545,26 +545,14 @@ def try_make_directory_shared(directory_path):
raise
def try_to_create_directory(directory_path, warn_if_exist=True):
def try_to_create_directory(directory_path):
"""Attempt to create a directory that is globally readable/writable.
Args:
directory_path: The path of the directory to create.
warn_if_exist (bool): Warn if the directory already exists.
"""
directory_path = os.path.expanduser(directory_path)
if not os.path.exists(directory_path):
try:
os.makedirs(directory_path)
except OSError as e:
if e.errno != errno.EEXIST:
raise e
if warn_if_exist:
logger = logging.getLogger("ray")
logger.warning(
"Attempted to create '{}', but the directory already "
"exists.".format(directory_path))
os.makedirs(directory_path, exist_ok=True)
# Change the log directory permissions so others can use it. This is
# important when multiple people are using the same machine.
try_make_directory_shared(directory_path)