Skip to content

Commit

Permalink
easy mvp
Browse files Browse the repository at this point in the history
  • Loading branch information
richardliaw committed Mar 11, 2017
1 parent 18c8e53 commit 211c747
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 3 deletions.
8 changes: 5 additions & 3 deletions webui/backend/ray_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def hgetall_as_dict(redis_conn, key):

# Cache information about the local schedulers.
local_schedulers = {}
errors = collections.defaultdict(list)
errors = []

def duration_to_string(duration):
"""Format a duration in seconds as a string.
Expand Down Expand Up @@ -145,11 +145,13 @@ async def listen_for_errors(redis_ip_address, redis_port):
result = await data_conn.execute("hget", error_key, "message")
result = result.decode("ascii")
# TODO: Maybe also get rid of coloring?
errors[worker].append(result)
errors.append({"worker_id": worker,
"task_id": task,
"error": result})
index += 1

async def handle_get_errors(websocket):
"""Renders error messages"""
"""Renders error messages"""
await websocket.send(json.dumps(errors))

node_info = collections.OrderedDict()
Expand Down
2 changes: 2 additions & 0 deletions webui/src/ray-app.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<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>
Expand All @@ -100,6 +101,7 @@
<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>
Expand Down
56 changes: 56 additions & 0 deletions webui/src/ray-errors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!--
@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">

<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="worker_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>

0 comments on commit 211c747

Please sign in to comment.