Commit ae63b0fd authored by Zixian Cai's avatar Zixian Cai

Structure of the website

parent 6cdf1abf
......@@ -44,3 +44,10 @@ def group_stats(datapoints):
result[k].append(v)
result = {k: Trails("", v) for k, v in result.items()}
return result
def group_stats_result(result):
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()
......@@ -15,7 +15,8 @@
from flask import Flask, render_template, request, flash, redirect, url_for
from mubench.conf import settings
from mubench.frontend.utils import group_stats
from mubench.frontend.utils import group_stats_result
from mubench.frontend.web import storage, changes
import click
import json
......@@ -23,6 +24,30 @@ app = Flask(__name__)
app.config['SECRET_KEY'] = settings.WEB_SECRET
@app.route("/<repo>/<rev>/<host>/visualize")
def result_visualize(repo, rev, host):
result = storage.load(repo, rev, host)
return render_template("visualize.html", result=result)
@app.route("/<repo>/<rev>/<host>/store", methods=["POST"])
def result_store(repo, rev, host):
if "logfile" not in request.files:
flash("No log file uploaded")
return redirect(url_for("index"))
logfile = request.files["logfile"]
storage.store(repo, rev, host, logfile.read())
return redirect(url_for("index"))
@app.route("/<repo>/<rev>/<host>/compare/<repo1>/<rev1>/<host1>")
def result_compare(repo, rev, host, repo1, rev1, host1):
result = storage.load(repo, rev, host)
result1 = storage.load(repo1, rev1, host1)
return render_template("changes.html",
result=changes.compare(result, result1))
@app.route("/visualize_file", methods=["POST"])
def visualize_file():
if "logfile" not in request.files:
......@@ -30,16 +55,24 @@ def visualize_file():
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()
group_stats_result(result)
return render_template("visualize.html", result=result)
@app.route("/tools")
def tools():
return render_template("tools.html")
@app.route("/")
def index():
return render_template("index.html")
repo, host = settings.WEB_POI_REPO, settings.WEB_POI_HOST
result = storage.load_relative(repo, host, 0)
group_stats_result(result)
result1 = storage.load_relative(repo, host, 1)
return render_template("index.html",
visualzing=result,
changes=result_compare(result, result1))
@click.command()
......
......@@ -12,3 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def compare(result, result1):
pass
#!/usr/bin/env python3
# Copyright 2017 The Australian National University
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
......@@ -12,3 +12,18 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from mubench.models.revision import GitRevision
from mubench.conf import settings
def load(repo, rev, host):
pass
def store(repo, rev, host, text_form):
pass
def load_relative(repo, host, num):
pass
......@@ -27,6 +27,13 @@
<div class="navbar-header">
<a class="navbar-brand" href="{{ url_for("index") }}">Mubench</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="{{ url_for("tools") }}">Tools</a></li>
<li><a href="http://microvm.org">About</a></li>
</ul>
</div>
</div>
</nav>
<div class="container">
......
{% extends 'base.html' %}
{% block body %}
{% include "changes_body.html" %}
{% endblock %}
\ No newline at end of file
......@@ -3,28 +3,15 @@
<div class="panel panel-primary">
<div class="panel-heading">How fast is Mu?</div>
<div class="panel-body">
{% include "visualize_summary.html" %}
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">What about improvement?</div>
<div class="panel-body">
<div class="panel-heading">How has Mu performance evolved over time?
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">Visualizing Log File</div>
<div class="panel-body">
<form action="{{ url_for('visualize_file') }}" 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>
{% include "changes_body.html" %}
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block body %}
<div class="panel panel-default">
<div class="panel-heading">Visualizing Log File</div>
<div class="panel-body">
<form action="{{ url_for('visualize_file') }}" 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' %}
{% macro responsive_header(elementID) -%}
(function () {
var d3 = Plotly.d3;
var WIDTH_IN_PERCENT_OF_PARENT = 100,
HEIGHT_IN_PERCENT_OF_PARENT = 100;
var gd3 = d3.select('#{{ elementID }}')
.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();
window.addEventListener("resize", function () {Plotly.Plots.resize(gd);});
{%- endmacro %}
{% macro responsive_footer() -%}
})();
{%- endmacro %}
{% include "visualize_marcos.html" %}
{% block body %}
<div class="panel panel-info">
<div class="panel-heading">Platform information</div>
......
{% macro responsive_header(elementID) -%}
(function () {
var d3 = Plotly.d3;
var WIDTH_IN_PERCENT_OF_PARENT = 100,
HEIGHT_IN_PERCENT_OF_PARENT = 100;
var gd3 = d3.select('#{{ elementID }}')
.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();
window.addEventListener("resize", function () {Plotly.Plots.resize(gd);});
{%- endmacro %}
{% macro responsive_footer() -%}
})();
{%- endmacro %}
\ No newline at end of file
{% include "visualize_marcos.html" %}
\ No newline at end of file
#!/usr/bin/env python3
# Copyright 2017 The Australian National University
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
......@@ -73,3 +73,7 @@ class LocalRevision(Revision):
def __str__(self):
return "LocalRevision({})".format(self.file)
class GitRevision(Revision):
pass
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