[tune] Fix Trial Logging File name (#1466)

This commit is contained in:
Richard Liaw
2018-01-25 17:57:40 -08:00
committed by GitHub
parent f3d2dc0ad4
commit e5c4d9ea0c
3 changed files with 49 additions and 3 deletions
+7 -1
View File
@@ -17,6 +17,7 @@ from ray.tune.result import TrainingResult, DEFAULT_RESULTS_DIR, pretty_print
from ray.utils import random_string, binary_to_hex
DEBUG_PRINT_INTERVAL = 5
MAX_LEN_IDENTIFIER = 130
class Resources(
@@ -337,6 +338,11 @@ class Trial(object):
logger_creator=logger_creator)
def __str__(self):
"""Combines ``env`` with ``trainable_name`` and ``experiment_tag``.
Truncates to MAX_LEN_IDENTIFIER (default is 130) to avoid problems
when creating logging directories.
"""
if "env" in self.config:
identifier = "{}_{}".format(
self.trainable_name, self.config["env"])
@@ -344,4 +350,4 @@ class Trial(object):
identifier = self.trainable_name
if self.experiment_tag:
identifier += "_" + self.experiment_tag
return identifier
return identifier[:MAX_LEN_IDENTIFIER]
+8 -1
View File
@@ -128,10 +128,17 @@ def _format_vars(resolved_vars):
last_string = False
pieces.append(k)
pieces.reverse()
out.append("_".join(pieces) + "=" + str(value))
out.append("_".join(pieces) + "=" + _clean_value(value))
return ",".join(out)
def _clean_value(value):
if isinstance(value, float):
return "{:.5}".format(value)
else:
return str(value)
def _generate_variants(spec):
spec = copy.deepcopy(spec)
unresolved = _unresolved_values(spec)