diff --git a/python/ray/autoscaler/log_timer.py b/python/ray/autoscaler/log_timer.py index 2ad9dc18e..dc7b7950c 100644 --- a/python/ray/autoscaler/log_timer.py +++ b/python/ray/autoscaler/log_timer.py @@ -5,13 +5,19 @@ logger = logging.getLogger(__name__) class LogTimer: - def __init__(self, message): + def __init__(self, message, show_status=False): self._message = message + self._show_status = show_status def __enter__(self): self._start_time = datetime.datetime.utcnow() - def __exit__(self, *_): + def __exit__(self, *error_vals): td = datetime.datetime.utcnow() - self._start_time - logger.info(self._message + - " [LogTimer={:.0f}ms]".format(td.total_seconds() * 1000)) + status = "" + if self._show_status: + status = "failed" if any(error_vals) else "succeeded" + logger.info(" ".join([ + self._message, status, + "[LogTimer={:.0f}ms]".format(td.total_seconds() * 1000) + ])) diff --git a/python/ray/autoscaler/updater.py b/python/ray/autoscaler/updater.py index 1ecf11363..026b6c905 100644 --- a/python/ray/autoscaler/updater.py +++ b/python/ray/autoscaler/updater.py @@ -423,16 +423,19 @@ class NodeUpdater: # Run init commands self.provider.set_node_tags( self.node_id, {TAG_RAY_NODE_STATUS: STATUS_SETTING_UP}) - with LogTimer(self.log_prefix + - "Initialization commands completed"): + with LogTimer( + self.log_prefix + "Initialization commands", + show_status=True): for cmd in self.initialization_commands: self.cmd_runner.run(cmd) - with LogTimer(self.log_prefix + "Setup commands completed"): + with LogTimer( + self.log_prefix + "Setup commands", show_status=True): for cmd in self.setup_commands: self.cmd_runner.run(cmd) - with LogTimer(self.log_prefix + "Ray start commands completed"): + with LogTimer( + self.log_prefix + "Ray start commands", show_status=True): for cmd in self.ray_start_commands: self.cmd_runner.run(cmd)