Skip to content

Commit

Permalink
Merge f3bf262 into 9cdd5ca
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaclarke committed Aug 19, 2021
2 parents 9cdd5ca + f3bf262 commit 3c23a6b
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 50 deletions.
2 changes: 1 addition & 1 deletion conbench/app/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def dataset_name(name):


def display_time(t):
return t.split(".")[0].replace("T", " ").rsplit(":", 1)[0]
return t.split(".")[0].replace("T", " ").rsplit(":", 1)[0] if t else ""


def set_display_language(benchmark, contexts):
Expand Down
3 changes: 3 additions & 0 deletions conbench/app/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def _augment(self, run):
repository_name = repository
if "github.com/" in repository:
repository_name = repository.split("github.com/")[1]
run["display_name"] = ""
if run["name"]:
run["display_name"] = run["name"].split(":", 1)[0]
run["commit"]["display_repository"] = repository_name

def _display_time(self, obj, field):
Expand Down
8 changes: 8 additions & 0 deletions conbench/app/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@

class Index(AppEndpoint, RunMixin):
def page(self, runs):
reasons = {r["display_name"] for r in runs if r["display_name"]}
commits = {r["commit"]["url"] for r in runs if r["commit"]["url"]}
authors = {
r["commit"]["author_name"] for r in runs if r["commit"]["author_name"]
}
return self.render_template(
"index.html",
application=Config.APPLICATION_NAME,
title="Home",
runs=runs,
has_reasons=len(reasons) > 0,
has_authors=len(authors) > 0,
has_commits=len(commits) > 0,
)

def get(self):
Expand Down
37 changes: 19 additions & 18 deletions conbench/entities/commit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import datetime
import functools
import json
import os
Expand All @@ -22,42 +21,40 @@ class Commit(Base, EntityMixin):
__tablename__ = "commit"
id = NotNull(s.String(50), primary_key=True, default=generate_uuid)
sha = NotNull(s.String(50))
parent = NotNull(s.String(50))
parent = Nullable(s.String(50))
repository = NotNull(s.String(100))
message = NotNull(s.String(250))
author_name = NotNull(s.String(100))
author_login = Nullable(s.String(50))
author_avatar = Nullable(s.String(100))
timestamp = NotNull(s.DateTime(timezone=False))
timestamp = Nullable(s.DateTime(timezone=False))

@staticmethod
def create_no_context():
commit = Commit.first(sha="none")
commit = Commit.first(sha="", repository="")
if not commit:
now = datetime.datetime.now(datetime.timezone.utc)
commit = Commit.create(
{
"sha": "none",
"repository": "none",
"parent": "",
"timestamp": now,
"message": "none",
"author_name": "none",
"sha": "",
"repository": "",
"parent": None,
"timestamp": None,
"message": "",
"author_name": "",
}
)
return commit

@staticmethod
def create_unknown_context(sha, repository):
now = datetime.datetime.now(datetime.timezone.utc)
return Commit.create(
{
"sha": sha,
"repository": repository,
"parent": "unknown",
"timestamp": now,
"message": "unknown",
"author_name": "unknown",
"parent": None,
"timestamp": None,
"message": "",
"author_name": "",
}
)

Expand Down Expand Up @@ -87,17 +84,21 @@ def create_github_context(sha, repository, github):

class _Serializer(EntitySerializer):
def _dump(self, commit):
url = None
if commit.repository and commit.sha:
url = f"{commit.repository}/commit/{commit.sha}"
timestamp = commit.timestamp.isoformat() if commit.timestamp else None
return {
"id": commit.id,
"sha": commit.sha,
"url": f"{commit.repository}/commit/{commit.sha}",
"url": url,
"parent_sha": commit.parent,
"repository": commit.repository,
"message": commit.message,
"author_name": commit.author_name,
"author_login": commit.author_login,
"author_avatar": commit.author_avatar,
"timestamp": commit.timestamp.isoformat(),
"timestamp": timestamp,
"links": {
"list": f.url_for("api.commits", _external=True),
"self": f.url_for("api.commit", commit_id=commit.id, _external=True),
Expand Down
1 change: 1 addition & 0 deletions conbench/entities/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def get_commit_index(repository):
ordered = (
Session.query(Commit.id, Commit.sha, Commit.timestamp)
.filter(Commit.repository == repository)
.filter(Commit.timestamp.isnot(None))
.order_by(Commit.timestamp.desc())
).cte("ordered_commits")
return Session.query(ordered, func.row_number().over().label("row_number"))
Expand Down
28 changes: 19 additions & 9 deletions conbench/templates/benchmark-entity.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,22 @@
<a href="{{ url_for('app.run', run_id=benchmark.run_id) }}">{{ benchmark.run_id }}</a>
</div>
</li>
{% if run and not run.commit.url and run.commit.display_repository %}
<li class="list-group-item" style="overflow-y: auto;">
<b>repository</b>
<div align="right" style="display:inline-block; float: right;">
<a href="{{ run.commit.repository }}">{{ run.commit.display_repository }}</a>
</div>
</li>
{% endif %}
{% if run.name %}
<li class="list-group-item" style="overflow-y: auto;">
<b>reason</b>
<div align="right" style="display:inline-block; float: right;">
{{ run.name }}
</div>
</li>
{% endif %}
<li class="list-group-item active">Result</li>
<li class="list-group-item" style="overflow-y: auto;">
<b>timestamp</b>
Expand All @@ -72,26 +82,34 @@

<div class="col-md-6">
<ul class="list-group">
{% if run %}
{% if run and run.commit.url %}
<li class="list-group-item active">Commit</li>
<li class="list-group-item" style="overflow-y: auto;">
<b>commit</b>
<div class="ellipsis-500" align="right" style="display:inline-block; float: right;">
{% if run.commit.message %}
<a href="{{ run.commit.url }}">{{ run.commit.message }}</a>
{% else %}
<a href="{{ run.commit.url }}">{{ run.commit.sha }}</a>
{% endif %}
</div>
</li>
{% if run.commit.display_timestamp %}
<li class="list-group-item" style="overflow-y: auto;">
<b>date</b>
<div align="right" style="display:inline-block; float: right;">
{{ run.commit.display_timestamp }}
</div>
</li>
{% endif %}
{% if run.commit.message %}
<li class="list-group-item" style="overflow-y: auto;">
<b>author</b>
<div align="right" style="display:inline-block; float: right;">
{{ run.commit.author_name }}
</div>
</li>
{% endif %}
<li class="list-group-item" style="overflow-y: auto;">
<b>repository</b>
<div align="right" style="display:inline-block; float: right;">
Expand All @@ -106,14 +124,6 @@
<div align="right" style="display:inline-block; float: right;">{{ v }}</div>
</li>
{% endfor %}
<li class="list-group-item" style="overflow-y: auto;">
<b>&nbsp;</b>
<div align="right" style="display:inline-block; float: right;">&nbsp;</div>
</li>
<li class="list-group-item" style="overflow-y: auto;">
<b>&nbsp;</b>
<div align="right" style="display:inline-block; float: right;">&nbsp;</div>
</li>
<li class="list-group-item active" >Context</li>
{% for k,v in benchmark.context.items() %}
<li class="list-group-item" style="overflow-y: auto;">
Expand Down
28 changes: 26 additions & 2 deletions conbench/templates/compare-entity.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,27 @@
</div>
</li>
{% if baseline_run %}
{% if baseline_run.commit.url %}
<li class="list-group-item" style="overflow-y: auto;">
<b>commit</b>
<div class="ellipsis-500" align="right" style="display:inline-block; float: right;">
<a href="{{ baseline_run.commit.url }}">{{ baseline_run.commit.message }}</a>
{% if baseline_run.commit.message %}
<a href="{{ baseline_run.commit.url }}">{{ baseline_run.commit.message }}</a>
{% else %}
<a href="{{ baseline_run.commit.url }}">{{ baseline_run.commit.sha }}</a>
{% endif %}
</div>
</li>
{% endif %}
{% if baseline_run.commit.display_timestamp %}
<li class="list-group-item" style="overflow-y: auto;">
<b>date</b>
<div align="right" style="display:inline-block; float: right;">
{{ baseline_run.commit.display_timestamp }}
</div>
</li>
{% endif %}
{% if baseline_run.commit.author_name %}
<li class="list-group-item" style="overflow-y: auto;">
<b>author</b>
<div align="right" style="display:inline-block; float: right;">
Expand All @@ -119,12 +128,15 @@
{% endif %}
</div>
</li>
{% endif %}
{% if baseline_run.commit.display_repository %}
<li class="list-group-item" style="overflow-y: auto;">
<b>repository</b>
<div align="right" style="display:inline-block; float: right;">
<a href="{{ baseline_run.commit.repository }}">{{ baseline_run.commit.display_repository }}</a>
</div>
</li>
{% endif %}
<li class="list-group-item" style="overflow-y: auto;">
<b>machine</b>
<div align="right" style="display:inline-block; float: right;">
Expand Down Expand Up @@ -195,18 +207,27 @@
</div>
</li>
{% if contender_run %}
{% if contender_run.commit.url %}
<li class="list-group-item" style="overflow-y: auto;">
<b>commit</b>
<div class="ellipsis-500" align="right" style="display:inline-block; float: right;">
<a href="{{ contender_run.commit.url }}">{{ contender_run.commit.message }}</a>
{% if contender_run.commit.message %}
<a href="{{ contender_run.commit.url }}">{{ contender_run.commit.message }}</a>
{% else %}
<a href="{{ contender_run.commit.url }}">{{ contender_run.commit.sha }}</a>
{% endif %}
</div>
</li>
{% endif %}
{% if contender_run.commit.display_timestamp %}
<li class="list-group-item" style="overflow-y: auto;">
<b>date</b>
<div align="right" style="display:inline-block; float: right;">
{{ contender_run.commit.display_timestamp }}
</div>
</li>
{% endif %}
{% if contender_run.commit.author_name %}
<li class="list-group-item" style="overflow-y: auto;">
<b>author</b>
<div align="right" style="display:inline-block; float: right;">
Expand All @@ -216,12 +237,15 @@
{% endif %}
</div>
</li>
{% endif %}
{% if contender_run.commit.display_repository %}
<li class="list-group-item" style="overflow-y: auto;">
<b>repository</b>
<div align="right" style="display:inline-block; float: right;">
<a href="{{ contender_run.commit.repository }}">{{ contender_run.commit.display_repository }}</a>
</div>
</li>
{% endif %}
<li class="list-group-item" style="overflow-y: auto;">
<b>machine</b>
<div align="right" style="display:inline-block; float: right;">
Expand Down
31 changes: 26 additions & 5 deletions conbench/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,51 @@ <h3>Language-independent Continuous Benchmarking (CB) Framework</h3>
<thead>
<tr>
<th scope="col">Run</th>
{% if has_authors %}
<th scope="col">Author</th>
{% endif %}
<th scope="col">Repository</th>
{% if has_commits %}
<th scope="col">Commit</th>
{% endif %}
<th scope="col">Machine</th>
{% if has_reasons %}
<th scope="col">Reason</th>
{% endif %}
</tr>
</thead>
<tbody>
{% for run in runs %}
<tr>
<td style="white-space: nowrap;"><a href="{{ url_for('app.run', run_id=run.id) }}">{{ run.display_timestamp }}</a></td>

{% if has_authors %}
<td style="white-space: nowrap;">
{% if run.commit.author_avatar %}
<image src="{{ run.commit.author_avatar }}" height="30" style="border-radius: 50%;">&nbsp;
{% endif %}
{{ run.commit.author_name }}
</td>
{% endif %}

<td style="white-space: nowrap;"><a href="{{ run.commit.repository }}">{{ run.commit.display_repository }}</a></td>
<td><a href="{{ run.commit.url }}">{{ run.commit.message }}</a></td>

{% if has_commits %}
{% if run.commit.message %}
<td><a href="{{ run.commit.url }}">{{ run.commit.message }}</a></td>
{% else %}
<td><a href="{{ run.commit.url }}">{{ run.commit.sha }}</a></td>
{% endif %}
{% endif %}

<td><div class="ellipsis-175">{{ run.machine.name }}</div></td>
{% if run.name %}
<td><div class="ellipsis-175">{{ run.name.split(":", 1)[0] }}</div></td>
{% else %}
<td></td>

{% if has_reasons %}
{% if run.display_name %}
<td><div class="ellipsis-175">{{ run.display_name }}</div></td>
{% else %}
<td></td>
{% endif %}
{% endif %}
</tr>
{% endfor %}
Expand Down

0 comments on commit 3c23a6b

Please sign in to comment.