[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
+7 -5
View File
@@ -7,6 +7,8 @@ try:
except ImportError:
setproctitle = None
import ray
class RayError(Exception):
"""Super class of all ray exception types."""
@@ -33,14 +35,14 @@ class RayTaskError(RayError):
traceback_str,
cause_cls,
pid=None,
host=None):
ip=None):
"""Initialize a RayTaskError."""
if setproctitle:
self.proctitle = setproctitle.getproctitle()
else:
self.proctitle = "ray_worker"
self.pid = pid or os.getpid()
self.host = host or os.uname()[1]
self.ip = ip or ray.services.get_node_ip_address()
self.function_name = function_name
self.traceback_str = traceback_str
self.cause_cls = cause_cls
@@ -67,7 +69,7 @@ class RayTaskError(RayError):
cls.__qualname__ = name
return cls(self.function_name, self.traceback_str, self.cause_cls,
self.pid, self.host)
self.pid, self.ip)
cls.original = self
return cls
@@ -78,9 +80,9 @@ class RayTaskError(RayError):
in_worker = False
for line in lines:
if line.startswith("Traceback "):
out.append("{}{}{} (pid={}, host={})".format(
out.append("{}{}{} (pid={}, ip={})".format(
colorama.Fore.CYAN, self.proctitle, colorama.Fore.RESET,
self.pid, self.host))
self.pid, self.ip))
elif in_worker:
in_worker = False
elif "ray/worker.py" in line or "ray/function_manager.py" in line: