Commit d806d35b authored by Zixian Cai's avatar Zixian Cai

Visualizing existing log file

parent d5134138
......@@ -42,11 +42,12 @@ def local(file, pipeline, skip_compile, dump):
revision = LocalRevision(file)
logger.info("Running tasks specified in file")
revision.run_tasksets(skip_compile)
go_through_pipelines(revision.tasksets, pipeline_names=pipeline.split(","))
if pipeline:
go_through_pipelines(revision.tasksets, pipeline_names=pipeline.split(","))
if dump:
logger.info("Dumping log to {}".format(dump))
with open(dump, "w") as logfile:
logs = [ts.get_log() for ts in revision.tasksets]
for x in logs:
x.update(platform_info())
json.dump(logs, logfile)
ts_logs = [ts.get_log() for ts in revision.tasksets]
log = platform_info()
log["ts"] = ts_logs
json.dump(log, logfile)
......@@ -16,6 +16,8 @@
import logging
from mubench.models.pipeline import pipelines
from mubench.util import get_cpu_info, get_hostname, get_uname
from collections import defaultdict
from mubench.models.trails import Trails
logger = logging.getLogger(__name__)
......@@ -32,3 +34,12 @@ def platform_info():
"uname": get_uname(),
"hostname": get_hostname()
}
def group_stats(datapoints):
result = defaultdict(list)
for pair in datapoints:
for k, v in pair.items():
result[k].append(v)
result = {k: Trails("", v) for k, v in result.items()}
return result
......@@ -13,8 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from flask import Flask, render_template, request
from flask import Flask, render_template, request, flash, redirect, url_for
from mubench.conf import settings
from mubench.frontend.utils import group_stats
import click
import json
......@@ -23,12 +24,17 @@ app.config['DEBUG'] = settings.WEB_DEBUG
app.config['SECRET_KEY'] = settings.WEB_SECRET
@app.route("/display", methods=["POST"])
def display():
path = request.form.get("path")
with open(path) as logfile:
result = json.loads(logfile.read())
return render_template("display.html", result=result)
@app.route("/visualize", methods=["POST"])
def visualize():
if "logfile" not in request.files:
flash("No log file uploaded")
return redirect(url_for("index"))
logfile = request.files["logfile"]
result = json.loads(logfile.read())
for ts in result["ts"]:
ts["datapoints_grouped"] = {k: group_stats(v) for k, v in ts["datapoints"].items()}
ts["metrics"] = iter(ts["datapoints"].values()).__next__()[0].keys()
return render_template("visualize.html", result=result)
@app.route("/")
......
......@@ -19,8 +19,16 @@
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="{{ url_for("index") }}">Mubench</a>
</div>
</div>
</nav>
<div class="container">
{% block body %}{% endblock %}
</div>
......
{% extends 'base.html' %}
{% block body %}
{% for ts in result %}
<h3>Name: {{ ts["name"] }}</h3>
<h3>Iteration: {{ ts["iterations"] }}</h3>
<h3>Platform information</h3>
<ul>
<li>CPU: {{ ts["cpu"] }}</li>
<li>uname: {{ ts["uname"] }}</li>
<li>Hostname: {{ ts["hostname"] }}</li>
</ul>
<h3>Benchmark</h3>
<ul>
<li>Name: {{ ts["benchmark"]["name"] }}</li>
<li>
Args:
<ol>
{% for arg in ts["benchmark"]["args"] %}
<li>{{ arg }}</li>
{% endfor %}
</ol>
</li>
</ul>
<h3>Callback</h3>
<ul>
<li>Name: {{ ts["callback"]["name"] }}</li>
<li>Param: {{ ts["callback"]["param"] }}</li>
</ul>
<h3>Datapoints</h3>
<ul>
{% for impl in ts["datapoints"].keys() %}
<li>{{ impl }}
<ol>
{% for point in ts["datapoints"][impl] %}
<li>
<ul>
{% for metric in point.keys() %}
<li>{{ metric }}: {{ point[metric] }}</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ol>
</li>
{% endfor %}
</ul>
{% endfor %}
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block body %}
<form action="{{ url_for('display') }}" method="post">
<label for="path">Path</label>
<input type="text" name="path" id="path">
<button type="submit" class="btn btn-primary">Display</button>
</form>
<div class="panel panel-default">
<div class="panel-heading">Visualize log file</div>
<div class="panel-body">
<form action="{{ url_for('visualize') }}" method="post"
enctype="multipart/form-data">
<div class="form-group">
<label for="file_1">Log File</label>
<input type="file" name="logfile" id="file_1">
</div>
<button type="submit" class="btn btn-primary">Display</button>
</form>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block body %}
<div class="panel panel-info">
<div class="panel-heading">Platform information</div>
<div class="panel-body">
<ul>
<li>CPU: {{ result["cpu"] }}</li>
<li>uname: {{ result["uname"] }}</li>
<li>Hostname: {{ result["hostname"] }}</li>
</ul>
</div>
</div>
{% for ts in result["ts"] %}
<div class="panel panel-primary">
<div class="panel-heading">TaskSet {{ ts["name"] }}</div>
<div class="panel-body">
<ul>
<li>Iteration: {{ ts["iterations"] }}</li>
<li>Benchmark: {{ ts["benchmark"]["name"] }}
<code>{{ ts["benchmark"]["args"] }}</code>
</li>
<li>Callback: {{ ts["callback"]["name"] }}
<code>{{ ts["callback"]["param"] }}</code>
</li>
</ul>
<div id="plot_ts_{{ ts["name"] }}"></div>
</div>
</div>
<script>
(function () {
var d3 = Plotly.d3;
var WIDTH_IN_PERCENT_OF_PARENT = 100,
HEIGHT_IN_PERCENT_OF_PARENT = 100;
var gd3 = d3.select('#plot_ts_{{ ts["name"] }}')
.style({
width: WIDTH_IN_PERCENT_OF_PARENT + '%',
'margin-left': (100 - WIDTH_IN_PERCENT_OF_PARENT) / 2 + '%',
height: HEIGHT_IN_PERCENT_OF_PARENT + 'vh',
'margin-top': (100 - HEIGHT_IN_PERCENT_OF_PARENT) / 2 + 'vh'
});
var gd = gd3.node();
var data = [];
{% for metric in ts["metrics"] %}
var temp_x = [];
var temp_y = [];
var temp_yerr = [];
{% for task in ts["datapoints_grouped"] %}
temp_x.push("{{ task }}");
temp_y.push({{ ts["datapoints_grouped"][task][metric].mean }});
temp_yerr.push({{ ts["datapoints_grouped"][task][metric].std }});
{% endfor %}
var trace_{{ metric }} = {
x: temp_x,
y: temp_y,
name: '{{ metric }}',
error_y: {
type: 'data',
array: temp_yerr,
visible: true
},
type: 'bar'
};
data.push(trace_{{ metric }});
{% endfor %}
var layout = {barmode: 'group'};
Plotly.newPlot('plot_ts_{{ ts["name"] }}', data, layout);
window.onresize = function () {
Plotly.Plots.resize(gd);
};
})();
</script>
{% endfor %}
{% endblock %}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment