mirror of
https://github.com/vale981/ray
synced 2025-03-06 02:21:39 -05:00
[autoscaler] Improve Logtimer log messages (#8753)
This commit is contained in:
parent
c1a97c8c04
commit
d452932740
2 changed files with 17 additions and 8 deletions
|
@ -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)
|
||||
]))
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue