mirror of
https://github.com/wassname/ray.git
synced 2026-07-09 16:41:43 +08:00
Error Messages - UI display (#360)
* backend ui work * instll block * easy mvp * Small changes.
This commit is contained in:
committed by
Robert Nishihara
parent
b1cb48159a
commit
ced13ca5b1
+45
-4
@@ -50,6 +50,7 @@ async def hgetall_as_dict(redis_conn, key):
|
||||
|
||||
# Cache information about the local schedulers.
|
||||
local_schedulers = {}
|
||||
errors = []
|
||||
|
||||
def duration_to_string(duration):
|
||||
"""Format a duration in seconds as a string.
|
||||
@@ -125,6 +126,35 @@ async def handle_get_drivers(websocket, redis_conn):
|
||||
reply = sorted(drivers, key=(lambda driver: driver["start time"]))[::-1]
|
||||
await websocket.send(json.dumps(reply))
|
||||
|
||||
async def listen_for_errors(redis_ip_address, redis_port):
|
||||
pubsub_conn = await aioredis.create_connection((redis_ip_address, redis_port), loop=loop)
|
||||
data_conn = await aioredis.create_connection((redis_ip_address, redis_port), loop=loop)
|
||||
|
||||
error_pattern = "__keyspace@0__:ErrorKeys"
|
||||
psub = await pubsub_conn.execute_pubsub("psubscribe", error_pattern)
|
||||
channel = pubsub_conn.pubsub_patterns[error_pattern]
|
||||
print("Listening for error messages...")
|
||||
index = 0
|
||||
while (await channel.wait_message()):
|
||||
msg = await channel.get()
|
||||
info = await data_conn.execute("lrange", "ErrorKeys", index, -1)
|
||||
|
||||
for error_key in info:
|
||||
worker, task = key_to_hex_identifiers(error_key)
|
||||
# TODO(richard): Filter out workers so that only relevant task errors are
|
||||
# necessary.
|
||||
result = await data_conn.execute("hget", error_key, "message")
|
||||
result = result.decode("ascii")
|
||||
# TODO(richard): Maybe also get rid of the coloring.
|
||||
errors.append({"driver_id": worker,
|
||||
"task_id": task,
|
||||
"error": result})
|
||||
index += 1
|
||||
|
||||
async def handle_get_errors(websocket):
|
||||
"""Send error messages to the frontend."""
|
||||
await websocket.send(json.dumps(errors))
|
||||
|
||||
node_info = collections.OrderedDict()
|
||||
worker_info = collections.OrderedDict()
|
||||
|
||||
@@ -245,12 +275,18 @@ async def send_heartbeats(websocket, redis_conn):
|
||||
continue
|
||||
local_schedulers[local_scheduler_id]["last_heartbeat"] = time.time()
|
||||
|
||||
async def serve_requests(websocket, path):
|
||||
redis_conn = await aioredis.create_connection((redis_ip_address, redis_port), loop=loop)
|
||||
async def cache_data_from_redis(redis_ip_address, redis_port):
|
||||
"""Open up ports to listen for new updates from Redis."""
|
||||
# TODO(richard): A lot of code needs to be ported in order to open new
|
||||
# websockets.
|
||||
|
||||
asyncio.ensure_future(listen_for_errors(redis_ip_address, redis_port))
|
||||
|
||||
async def serve_requests(websocket, path):
|
||||
# We loop infinitely because otherwise the websocket will be closed.
|
||||
# TODO(rkn): Maybe we should open a new web sockets for every request instead
|
||||
# of looping here.
|
||||
redis_conn = await aioredis.create_connection((redis_ip_address, redis_port), loop=loop)
|
||||
while True:
|
||||
command = json.loads(await websocket.recv())
|
||||
print("received command {}".format(command))
|
||||
@@ -261,6 +297,8 @@ async def serve_requests(websocket, path):
|
||||
await handle_get_drivers(websocket, redis_conn)
|
||||
elif command["command"] == "get-recent-tasks":
|
||||
await handle_get_recent_tasks(websocket, redis_conn, command["num"])
|
||||
elif command["command"] == "get-errors":
|
||||
await handle_get_errors(websocket)
|
||||
elif command["command"] == "get-heartbeats":
|
||||
await send_heartbeats(websocket, redis_conn)
|
||||
|
||||
@@ -335,9 +373,12 @@ if __name__ == "__main__":
|
||||
redis_ip_address, redis_port = redis_address[0], int(redis_address[1])
|
||||
|
||||
# The port here must match the value used by the frontend to connect over
|
||||
# websockets.
|
||||
# websockets. TODO(richard): Automatically increment the port if it is already
|
||||
# taken.
|
||||
port = 8888
|
||||
start_server = websockets.serve(serve_requests, "localhost", port)
|
||||
|
||||
loop.run_until_complete(cache_data_from_redis(redis_ip_address, redis_port))
|
||||
|
||||
start_server = websockets.serve(serve_requests, "localhost", port)
|
||||
loop.run_until_complete(start_server)
|
||||
loop.run_forever()
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
||||
+2
-10
@@ -1,13 +1,3 @@
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<link rel="import" href="../bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="../bower_components/app-layout/app-drawer/app-drawer.html">
|
||||
<link rel="import" href="../bower_components/app-layout/app-drawer-layout/app-drawer-layout.html">
|
||||
@@ -75,6 +65,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
<a name="objects" href="/objects">Objects</a>
|
||||
<a name="tasks" href="/tasks">Tasks</a>
|
||||
<a name="events" href="/events">Events</a>
|
||||
<a name="errors" href="/errors">Errors</a>
|
||||
<a name="timeline" href="/timeline">Timeline</a>
|
||||
<a name="recent-tasks" href="/recent-tasks">Recent Tasks</a>
|
||||
</iron-selector>
|
||||
@@ -100,6 +91,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
<ray-objects name="objects"></ray-objects>
|
||||
<ray-tasks name="tasks"></ray-tasks>
|
||||
<ray-events name="events"></ray-events>
|
||||
<ray-errors name="errors"></ray-errors>
|
||||
<ray-timeline name="timeline"></ray-timeline>
|
||||
<ray-recent-tasks name="recent-tasks"></ray-recent-tasks>
|
||||
<ray-view404 name="view404"></ray-view404>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<link rel="import" href="../bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="shared-styles.html">
|
||||
|
||||
<dom-module id="ray-errors">
|
||||
<template>
|
||||
<style include="shared-styles">
|
||||
:host {
|
||||
display: block;
|
||||
|
||||
padding: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="card">
|
||||
<h1>Errors</h1>
|
||||
<vaadin-grid id="errors">
|
||||
<table>
|
||||
<colgroup>
|
||||
<col name="driver_id" sortable="" sort-direction="desc"/>
|
||||
<col name="task_id" sortable="" sort-direction="desc"/>
|
||||
<col name="error" sortable="" sort-direction="desc"/>
|
||||
</colgroup>
|
||||
</table>
|
||||
</vaadin-grid>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var backend_address = "ws://127.0.0.1:8888";
|
||||
Polymer({
|
||||
is: 'ray-errors',
|
||||
ready: function() {
|
||||
var eventSocket = new WebSocket(backend_address);
|
||||
var errors = Polymer.dom(this.root).querySelector("#errors");
|
||||
|
||||
eventSocket.onopen = function() {
|
||||
eventSocket.send(JSON.stringify({"command": "get-errors"}));
|
||||
}
|
||||
eventSocket.onmessage = function(answer) {
|
||||
console.dir(answer.data);
|
||||
errors.items = JSON.parse(answer.data);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</dom-module>
|
||||
@@ -1,13 +1,3 @@
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<link rel="import" href="../bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="shared-styles.html">
|
||||
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<link rel="import" href="../bower_components/iron-icon/iron-icon.html">
|
||||
<link rel="import" href="../bower_components/iron-iconset-svg/iron-iconset-svg.html">
|
||||
|
||||
@@ -28,4 +18,4 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
</g>
|
||||
</defs>
|
||||
</svg>
|
||||
</iron-iconset-svg>
|
||||
</iron-iconset-svg>
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<link rel="import" href="../bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="shared-styles.html">
|
||||
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<link rel="import" href="../bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="shared-styles.html">
|
||||
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<link rel="import" href="../bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="shared-styles.html">
|
||||
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<link rel="import" href="../bower_components/polymer/polymer.html">
|
||||
<link rel="import" href="shared-styles.html">
|
||||
|
||||
|
||||
Reference in New Issue
Block a user