mirror of
https://github.com/wassname/ray.git
synced 2026-07-20 12:40:20 +08:00
[tune] Tune onto Logging Module (#2882)
Moves Tune onto logging in Python. Ignores examples and tests.
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user