mirror of
https://github.com/wassname/ray.git
synced 2026-07-02 07:04:46 +08:00
[tune] Fix Trial Logging File name (#1466)
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user