mirror of
https://github.com/wassname/ray.git
synced 2026-07-01 17:45:40 +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
parent
970cd78701
commit
5b40408678
+2
-14
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user