[Dashboard] Improve handling of logs and errors in dashboard backend (#5857)

* Improve handling of logs and errors in dashboard backend

* Update nested dict comprehension for clarity
This commit is contained in:
Mitchell Stern
2019-10-10 11:59:54 -07:00
committed by Eric Liang
parent 1a8ac3db46
commit 195ca43e9c
7 changed files with 278 additions and 230 deletions
+3 -12
View File
@@ -9,7 +9,6 @@ import os
import traceback
import time
import datetime
from socket import AddressFamily
try:
import psutil
@@ -19,6 +18,7 @@ except ImportError:
sys.exit(1)
import ray.ray_constants as ray_constants
import ray.services
import ray.utils
# Logger for this module. It should be configured at the entry point
@@ -52,15 +52,6 @@ def is_worker(cmdline):
return cmdline and cmdline[0].startswith("ray_")
def determine_ip_address():
"""Return the first IP address for an ethernet interface on the system."""
addrs = [
x.address for k, v in psutil.net_if_addrs().items() if k[0] == "e"
for x in v if x.family == AddressFamily.AF_INET
]
return addrs[0]
def to_posix_time(dt):
return (dt - datetime.datetime(1970, 1, 1)).total_seconds()
@@ -77,7 +68,7 @@ class Reporter(object):
def __init__(self, redis_address, redis_password=None):
"""Initialize the reporter object."""
self.cpu_counts = (psutil.cpu_count(), psutil.cpu_count(logical=False))
self.ip_addr = determine_ip_address()
self.ip = ray.services.get_node_ip_address()
self.hostname = os.uname().nodename
_ = psutil.cpu_percent() # For initialization
@@ -145,7 +136,7 @@ class Reporter(object):
return {
"now": now,
"hostname": self.hostname,
"ip": self.ip_addr,
"ip": self.ip,
"cpu": self.get_cpu_percent(),
"cpus": self.cpu_counts,
"mem": self.get_mem_usage(),