mirror of
https://github.com/wassname/ray.git
synced 2026-08-10 12:30:14 +08:00
[tune] use dated experiment dir per default (#11104)
This commit is contained in:
@@ -10,7 +10,7 @@ from ray.tune.result import DEFAULT_RESULTS_DIR
|
||||
from ray.tune.sample import Domain
|
||||
from ray.tune.stopper import CombinedStopper, FunctionStopper, Stopper, \
|
||||
TimeoutStopper
|
||||
from ray.tune.utils import detect_checkpoint_function
|
||||
from ray.tune.utils import date_str, detect_checkpoint_function
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -137,8 +137,18 @@ class Experiment:
|
||||
"within your trainable function.")
|
||||
self._run_identifier = Experiment.register_if_needed(run)
|
||||
self.name = name or self._run_identifier
|
||||
|
||||
# If the name has been set explicitly, we don't want to create
|
||||
# dated directories. The same is true for string run identifiers.
|
||||
if int(os.environ.get("TUNE_DISABLE_DATED_SUBDIR", 0)) == 1 or name \
|
||||
or isinstance(run, str):
|
||||
self.dir_name = self.name
|
||||
else:
|
||||
self.dir_name = "{}_{}".format(self.name, date_str())
|
||||
|
||||
if upload_dir:
|
||||
self.remote_checkpoint_dir = os.path.join(upload_dir, self.name)
|
||||
self.remote_checkpoint_dir = os.path.join(upload_dir,
|
||||
self.dir_name)
|
||||
else:
|
||||
self.remote_checkpoint_dir = None
|
||||
|
||||
@@ -249,8 +259,16 @@ class Experiment:
|
||||
return run_object
|
||||
elif isinstance(run_object, type) or callable(run_object):
|
||||
name = "DEFAULT"
|
||||
if hasattr(run_object, "__name__"):
|
||||
name = run_object.__name__
|
||||
if hasattr(run_object, "_name"):
|
||||
name = run_object._name
|
||||
elif hasattr(run_object, "__name__"):
|
||||
fn_name = run_object.__name__
|
||||
if fn_name == "<lambda>":
|
||||
name = "lambda"
|
||||
elif fn_name.startswith("<"):
|
||||
name = "DEFAULT"
|
||||
else:
|
||||
name = fn_name
|
||||
else:
|
||||
logger.warning(
|
||||
"No name detected on trainable. Using {}.".format(name))
|
||||
@@ -287,7 +305,7 @@ class Experiment:
|
||||
@property
|
||||
def checkpoint_dir(self):
|
||||
if self.local_dir:
|
||||
return os.path.join(self.local_dir, self.name)
|
||||
return os.path.join(self.local_dir, self.dir_name)
|
||||
|
||||
@property
|
||||
def run_identifier(self):
|
||||
|
||||
Reference in New Issue
Block a user