-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Render rich output in dashboard, pipeline pages
This feature allows users to render custom HTML data onto the HTML dashboard, allowing Litani jobs to display their results through tables, graphs, and other HTML format. This can be done both for the front page or on the pipeline page. The intention is that individual litani jobs can be used to measure metrics, and then print those metrics out in an easily-viewable format. Jobs that calculate metrics for the entire run can present those metrics as a graph on the front page. Jobs that calculate metrics for a single pipeline (or proof) can display the result on the pipeline page. Users use this feature by adding a tag to a litani job, using the --tags flag. If a job is tagged with front-page-text, Litani will render the job's output onto the front page, in its own section. A tag of literal-stdout will make Litani render the job's output onto the pipeline page, but without any HTML escaping. This feature fixes #81 and fixes #82.
- Loading branch information
Showing
21 changed files
with
570 additions
and
14 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 |
---|---|---|
|
@@ -5,6 +5,8 @@ test/output | |
doc/tmp | ||
doc/out | ||
|
||
examples/rich-output/*.csv | ||
|
||
__pycache__/ | ||
|
||
build.ninja |
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,10 @@ | ||
README | ||
|
||
The run-all.py script will run examples that demonstrate how jobs in Litani can | ||
display rich output either on the dashboard or pipeline pages | ||
|
||
To try this out, run | ||
|
||
LITANI=../../litani ./run-all.py | ||
|
||
in this directory. |
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,42 @@ | ||
<html> | ||
<style> | ||
table { | ||
font-family: Helvetica, sans-serif; | ||
border-collapse: collapse; | ||
width: 100%; | ||
} | ||
|
||
td, th { | ||
border: 1px solid #b0e0e6; | ||
text-align: left; | ||
padding: 8px; | ||
} | ||
|
||
tr:nth-child(odd) { | ||
background-color: #b0e0e6; | ||
} | ||
</style> | ||
<body> | ||
<div id="assumptions"> | ||
<table> | ||
<tr> | ||
<th>Assumption to check</th> | ||
<th>Difficulty</th> | ||
</tr> | ||
<tr> | ||
<td>Bound of input size function</td> | ||
<td>Easy</td> | ||
</tr> | ||
<tr> | ||
<td>Harness</td> | ||
<td>Medium</td> | ||
</tr> | ||
<tr> | ||
<td>Function specifications</td> | ||
<td>Hard</td> | ||
</tr> | ||
</table> | ||
</div> | ||
</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 @@ | ||
pipeline #Assumptions | ||
"Class\\\_A" 5 | ||
"Class\\\_B" 1 | ||
"Class\\\_C" 2 | ||
"Class\\\_D" 8 | ||
"Class\\\_E" 4 | ||
"Class\\\_F" 0 |
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 @@ | ||
set terminal svg noenhanced size 565,1096 | ||
set style data histogram | ||
set style fill solid border | ||
set style histogram clustered | ||
set xtics rotate out | ||
set yrange [ 0 : 10 ] | ||
plot for [COL=2:2] 'file.dat' using COL:xticlabels(1) title columnheader |
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,41 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). | ||
# You may not use this file except in compliance with the License. | ||
# A copy of the License is located at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# or in the "license" file accompanying this file. This file 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. | ||
|
||
LITANI=${LITANI:-litani} | ||
|
||
if [ "$1" != "--no-standalone" ]; then | ||
"${LITANI}" init --project-name "literal-stdout-examples" | ||
fi | ||
|
||
"${LITANI}" add-job \ | ||
--pipeline-name "verify assumptions" \ | ||
--description "list out assumptions" \ | ||
--command "cat assumptions.html" \ | ||
--ci-stage test \ | ||
--phony-outputs assumptions.html \ | ||
--tags literal-stdout | ||
|
||
"${LITANI}" add-job \ | ||
--pipeline-name "conduct analysis" \ | ||
--description "generate the histogram" \ | ||
--command "gnuplot -c histogram.dat" \ | ||
--ci-stage report \ | ||
--inputs file.dat \ | ||
--phony-outputs histogram.svg \ | ||
--tags literal-stdout | ||
|
||
if [ "$1" != "--no-standalone" ]; then | ||
"${LITANI}" run-build | ||
fi |
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,47 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). | ||
# You may not use this file except in compliance with the License. | ||
# A copy of the License is located at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# or in the "license" file accompanying this file. This file 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. | ||
|
||
LITANI=${LITANI:-litani} | ||
|
||
if [ "$1" != "--no-standalone" ]; then | ||
"${LITANI}" init --project-name "front-page-output examples" | ||
fi | ||
|
||
"${LITANI}" add-job \ | ||
--pipeline-name "fibonacci" \ | ||
--description "write fibonacci to csv" \ | ||
--command "python3 scripts/fib.py -o fib.csv" \ | ||
--ci-stage test \ | ||
--outputs "fib.csv" | ||
|
||
"${LITANI}" add-job \ | ||
--pipeline-name "fibonacci" \ | ||
--description "plot fibonacci results" \ | ||
--command "gnuplot scripts/fib.plt" \ | ||
--ci-stage report \ | ||
--inputs "fib.csv" \ | ||
--tags "front-page-text" | ||
|
||
"${LITANI}" add-job \ | ||
--pipeline-name "fibonacci" \ | ||
--description "table fibonacci results" \ | ||
--command "python3 scripts/fib-table.py -i fib.csv" \ | ||
--ci-stage report \ | ||
--inputs "fib.csv" \ | ||
--tags "front-page-text" | ||
|
||
if [ "$1" != "--no-standalone" ]; then | ||
"${LITANI}" run-build | ||
fi |
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,41 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). | ||
# You may not use this file except in compliance with the License. | ||
# A copy of the License is located at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# or in the "license" file accompanying this file. This file 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. | ||
|
||
LITANI=${LITANI:-litani} | ||
|
||
if [ "$1" != "--no-standalone" ]; then | ||
"${LITANI}" init \ | ||
--project-name "front-page-output and literal-stdout examples" | ||
fi | ||
|
||
"${LITANI}" add-job \ | ||
--pipeline-name "sin" \ | ||
--description "write sin to csv" \ | ||
--command "python3 scripts/sin.py -o sin.csv" \ | ||
--ci-stage test \ | ||
--outputs "sin.csv" | ||
|
||
"${LITANI}" add-job \ | ||
--pipeline-name "sin" \ | ||
--description "display sin results" \ | ||
--command \ | ||
"gnuplot scripts/sin.plt; python3 scripts/sin-output.py -i sin.csv" \ | ||
--ci-stage report \ | ||
--inputs "sin.csv" \ | ||
--tags front-page-text literal-stdout | ||
|
||
if [ "$1" != "--no-standalone" ]; then | ||
"${LITANI}" run-build | ||
fi |
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,34 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). | ||
# You may not use this file except in compliance with the License. | ||
# A copy of the License is located at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# or in the "license" file accompanying this file. This file 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. | ||
|
||
|
||
import os | ||
import pathlib | ||
import re | ||
import subprocess | ||
|
||
|
||
litani = os.getenv("LITANI", "litani") | ||
this_dir = pathlib.Path(__file__).parent | ||
|
||
subprocess.run( | ||
[litani, "init", "--project-name", "rich-output-examples"], check=True) | ||
|
||
pat = re.compile(r"run-\d.sh") | ||
for fyle in this_dir.iterdir(): | ||
if pat.match(fyle.name): | ||
subprocess.run([fyle, "--no-standalone"], check=True) | ||
|
||
subprocess.run([litani, "run-build"], check=True) |
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,40 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). | ||
# You may not use this file except in compliance with the License. | ||
# A copy of the License is located at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# or in the "license" file accompanying this file. This file 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. | ||
|
||
import argparse | ||
import jinja2 | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-i", "--input", required=True, help="input csv") | ||
args = parser.parse_args() | ||
|
||
data = {} | ||
with open(args.input, "r") as handle: | ||
for line in handle: | ||
values = line.split(',') | ||
data[int(values[0].strip())] = int(values[1].strip()) | ||
|
||
env = jinja2.Environment( | ||
loader=jinja2.FileSystemLoader("./templates"), | ||
autoescape=jinja2.select_autoescape( | ||
enabled_extensions=('csv'), | ||
default_for_string=True)) | ||
table_template = env.get_template("fib-table.jinja.html") | ||
table = table_template.render(data=data) | ||
print(table) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,5 @@ | ||
set term svg | ||
set style fill solid border | ||
set xlabel "nth fibonacci number" | ||
set ylabel "value" | ||
plot "fib.csv" with linespoints |
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,32 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). | ||
# You may not use this file except in compliance with the License. | ||
# A copy of the License is located at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# or in the "license" file accompanying this file. This file 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. | ||
|
||
import argparse | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-o", "--output", required=True, help="output file") | ||
args = parser.parse_args() | ||
n = 10 | ||
fib = [0] * n | ||
fib[1] = 1 | ||
for i in range(2, n): | ||
fib[i] = fib[i-1] + fib[i-2] | ||
with open(args.output, "w") as handle: | ||
for index, value in enumerate(fib, 1): | ||
print(f"{index}, {value}", file=handle) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,40 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). | ||
# You may not use this file except in compliance with the License. | ||
# A copy of the License is located at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# or in the "license" file accompanying this file. This file 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. | ||
|
||
import argparse | ||
import jinja2 | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-i", "--input", required=True, help="input csv") | ||
args = parser.parse_args() | ||
|
||
data = {} | ||
with open(args.input, "r") as handle: | ||
for line in handle: | ||
values = line.split(',') | ||
data[float(values[0].strip())] = float(values[1].strip()) | ||
|
||
env = jinja2.Environment( | ||
loader=jinja2.FileSystemLoader("./templates"), | ||
autoescape=jinja2.select_autoescape( | ||
enabled_extensions=('csv'), | ||
default_for_string=True)) | ||
table_template = env.get_template("sin-output.jinja.html") | ||
output = table_template.render(data=data) | ||
print(output) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,5 @@ | ||
set term svg | ||
set style fill solid border | ||
set xlabel "x" | ||
set ylabel "sin(x)" | ||
plot 0, "sin.csv" smooth csplines |
Oops, something went wrong.