[tune] Tune onto Logging Module (#2882)

Moves Tune onto logging in Python. Ignores examples and tests.
This commit is contained in:
Richard Liaw
2018-09-16 12:09:36 -07:00
committed by GitHub
parent a8248e8628
commit f372f48bf3
17 changed files with 121 additions and 63 deletions
+7 -3
View File
@@ -3,10 +3,13 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import logging
import traceback
from ray.tune.trial import Trial, Checkpoint
logger = logging.getLogger(__name__)
class TrialExecutor(object):
"""Manages platform-specific details such as resource handling
@@ -66,14 +69,15 @@ class TrialExecutor(object):
error_msg (str): Optional error message.
"""
try:
print("Attempting to recover trial state from last checkpoint")
logger.info(
"Attempting to recover trial state from last checkpoint")
self.stop_trial(
trial, error=True, error_msg=error_msg, stop_logger=False)
trial.result_logger.flush()
self.start_trial(trial)
except Exception:
error_msg = traceback.format_exc()
print("Error recovering trial from checkpoint, abort:", error_msg)
logger.exception("Error recovering trial from checkpoint, abort.")
self.stop_trial(trial, error=True, error_msg=error_msg)
def continue_training(self, trial):
@@ -92,7 +96,7 @@ class TrialExecutor(object):
self.stop_trial(trial, stop_logger=False)
trial.status = Trial.PAUSED
except Exception:
print("Error pausing runner:", traceback.format_exc())
logger.exception("Error pausing runner.")
trial.status = Trial.ERROR
def unpause_trial(self, trial):