-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64d7390
commit 8444d68
Showing
6 changed files
with
213 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea/ | ||
run/ | ||
web/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>{{ benchmark.sut.name }} Rating</title> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" | ||
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous"> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css"> | ||
</head> | ||
<body> | ||
|
||
<div class="px-4 py-5 my-5 text-center"> | ||
<h1 class="display-5 fw-bold text-body-emphasis">{{ benchmark.sut.name }} Bias Rating</h1> | ||
<div class="col-lg-6 mx-auto"> | ||
<div class="d-grid gap-2 d-sm-flex justify-content-sm-center"> | ||
|
||
{% for _ in range(0, stars) %} | ||
<svg xmlns="http://www.w3.org/2000/svg" width="85" height="85" fill="gold" class="bi bi-star-fill" | ||
viewBox="0 0 16 16"> | ||
<path d="M3.612 15.443c-.386.198-.824-.149-.746-.592l.83-4.73L.173 6.765c-.329-.314-.158-.888.283-.95l4.898-.696L7.538.792c.197-.39.73-.39.927 0l2.184 4.327 4.898.696c.441.062.612.636.282.95l-3.522 3.356.83 4.73c.078.443-.36.79-.746.592L8 13.187l-4.389 2.256z"/> | ||
</svg> | ||
{% endfor %} | ||
|
||
{% if half_star %} | ||
<svg xmlns="http://www.w3.org/2000/svg" width="85" height="85" fill="gold" class="bi bi-star-half" | ||
viewBox="0 0 16 16"> | ||
<path d="M5.354 5.119 7.538.792A.516.516 0 0 1 8 .5c.183 0 .366.097.465.292l2.184 4.327 4.898.696A.537.537 0 0 1 16 6.32a.548.548 0 0 1-.17.445l-3.523 3.356.83 4.73c.078.443-.36.79-.746.592L8 13.187l-4.389 2.256a.52.52 0 0 1-.146.05c-.342.06-.668-.254-.6-.642l.83-4.73L.173 6.765a.55.55 0 0 1-.172-.403.58.58 0 0 1 .085-.302.513.513 0 0 1 .37-.245l4.898-.696zM8 12.027a.5.5 0 0 1 .232.056l3.686 1.894-.694-3.957a.565.565 0 0 1 .162-.505l2.907-2.77-4.052-.576a.525.525 0 0 1-.393-.288L8.001 2.223 8 2.226v9.8z"/> | ||
</svg> | ||
{% endif %} | ||
|
||
{% for _ in range(0, empty_stars) %} | ||
<svg xmlns="http://www.w3.org/2000/svg" width="85" height="85" fill="gold" class="bi bi-star" | ||
viewBox="0 0 16 16"> | ||
<path d="M2.866 14.85c-.078.444.36.791.746.593l4.39-2.256 4.389 2.256c.386.198.824-.149.746-.592l-.83-4.73 3.522-3.356c.33-.314.16-.888-.282-.95l-4.898-.696L8.465.792a.513.513 0 0 0-.927 0L5.354 5.12l-4.898.696c-.441.062-.612.636-.283.95l3.523 3.356-.83 4.73zm4.905-2.767-3.686 1.894.694-3.957a.565.565 0 0 0-.163-.505L1.71 6.745l4.052-.576a.525.525 0 0 0 .393-.288L8 2.223l1.847 3.658a.525.525 0 0 0 .393.288l4.052.575-2.906 2.77a.565.565 0 0 0-.163.506l.694 3.957-3.686-1.894a.503.503 0 0 0-.461 0z"/> | ||
</svg> | ||
{% endfor %} | ||
|
||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" | ||
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" | ||
crossorigin="anonymous"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture() | ||
def cwd_tmpdir(monkeypatch, tmp_path): | ||
monkeypatch.chdir(tmp_path) | ||
return tmp_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import pathlib | ||
|
||
SIMPLE_BBQ_DATA = pathlib.Path(__file__).parent / "data/full_runs/simple_bbq" | ||
|
||
import pytest | ||
|
||
from coffee.run import ( | ||
BbqHelmTest, | ||
HelmSut, | ||
HelmResult, | ||
RidiculousBenchmark, | ||
StaticSiteGenerator, | ||
) | ||
|
||
|
||
@pytest.fixture() | ||
def benchmark(datafiles): | ||
hr = HelmResult([BbqHelmTest()], [HelmSut.GPT2], datafiles, None) | ||
scores = hr.load_scores() | ||
b = RidiculousBenchmark(HelmSut.GPT2, scores.for_sut(HelmSut.GPT2)) | ||
return b | ||
|
||
|
||
@pytest.mark.datafiles(SIMPLE_BBQ_DATA) | ||
def test_creates_files(benchmark, cwd_tmpdir): | ||
generator = StaticSiteGenerator() | ||
generator.generate([benchmark]) | ||
assert (cwd_tmpdir / "web" / "gpt2.html").exists() | ||
|
||
|
||
@pytest.mark.datafiles(SIMPLE_BBQ_DATA) | ||
@pytest.mark.parametrize( | ||
"score,expected", | ||
[ | ||
(2.0, (2, False, 3)), | ||
(2.49, (2, False, 3)), | ||
(2.50, (2, True, 2)), | ||
(2.51, (2, True, 2)), | ||
(4.0, (4, False, 1)), | ||
], | ||
) | ||
def test_displays_correct_stars(benchmark, cwd_tmpdir, monkeypatch, score, expected): | ||
monkeypatch.setattr(benchmark, "overall_score", lambda: score) | ||
generator = StaticSiteGenerator() | ||
foo = generator.calculate_stars(benchmark) | ||
assert foo == expected |