Skip to content

Commit aff9245

Browse files
committed
Fix problem with newer version of pandas
1 parent 7623a81 commit aff9245

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
pandas==1.2.3
1+
pandas==1.4.1
22
plotly==5.6.0
3-
reports==0.4.1
3+
jinja2==3.1.1

visualization/visualize_results.py

+29-14
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
import os
1717
import pandas as pd
1818
import plotly.io
19-
from reports import Report
19+
from jinja2 import Environment, FileSystemLoader
2020
import plotly.express as px
2121

2222

2323

2424
AMOUNT_OF_TESTS_IN_TOP = 3
25-
RESULT_PATH = "../target/coppers_results/"
25+
RESULT_PATH = "../results/"
2626

2727

2828
def is_coppers_file(filename):
@@ -146,31 +146,46 @@ def comparison_to_last(data):
146146

147147

148148
def main():
149-
rep = Report("template")
149+
env = Environment()
150+
env.loader = FileSystemLoader("template")
151+
template = env.get_template("index.html")
152+
jinja = {}
153+
150154
results = get_data()
151155
amount_of_results = len([filename for filename in os.listdir(RESULT_PATH) if "json" in filename])
152156

153157
if amount_of_results > 2:
154-
rep.jinja['over_time'] = True
155-
rep.jinja['plot_energy_over_time'] = visualize_over_time()
158+
jinja['over_time'] = True
159+
jinja['plot_energy_over_time'] = visualize_over_time()
156160

157161
sorted_tests = sorted(results["tests"], reverse=True, key=lambda item: item["uj"])
158162
n = float(results["number_of_repeats"])
159-
rep.jinja['amount_top'] = AMOUNT_OF_TESTS_IN_TOP
160-
rep.jinja['most_energy_consuming_names'] = [sorted_tests[i]['name'] for i in range(AMOUNT_OF_TESTS_IN_TOP)]
161-
rep.jinja['most_energy_consuming_usages'] = [sorted_tests[i]['uj']/n for i in range(AMOUNT_OF_TESTS_IN_TOP)]
162-
rep.jinja['least_energy_consuming_names'] = [sorted_tests[-(i+1)]['name'] for i in range(AMOUNT_OF_TESTS_IN_TOP)]
163-
rep.jinja['least_energy_consuming_usages'] = [sorted_tests[-(i+1)]['uj']/n for i in range(AMOUNT_OF_TESTS_IN_TOP)]
163+
jinja['amount_top'] = AMOUNT_OF_TESTS_IN_TOP
164+
jinja['most_energy_consuming_names'] = [sorted_tests[i]['name'] for i in range(AMOUNT_OF_TESTS_IN_TOP)]
165+
jinja['most_energy_consuming_usages'] = [sorted_tests[i]['uj']/n for i in range(AMOUNT_OF_TESTS_IN_TOP)]
166+
jinja['least_energy_consuming_names'] = [sorted_tests[-(i+1)]['name'] for i in range(AMOUNT_OF_TESTS_IN_TOP)]
167+
jinja['least_energy_consuming_usages'] = [sorted_tests[-(i+1)]['uj']/n for i in range(AMOUNT_OF_TESTS_IN_TOP)]
164168

165169
if amount_of_results > 1:
166-
rep.jinja["compare_to_last"] = True
167-
rep.jinja["overall_change"], rep.jinja["comparison_table"] = comparison_to_last(results)
170+
jinja["compare_to_last"] = True
171+
jinja["overall_change"], jinja["comparison_table"] = comparison_to_last(results)
168172

169-
rep.jinja['all_tests_plot'] = visualize_all_tests(sorted_tests, n)
173+
jinja['all_tests_plot'] = visualize_all_tests(sorted_tests, n)
170174

171-
rep.create_report(onweb=False)
175+
generate_report(template, jinja)
172176
print("------- Generated report of energy consumption results -------")
173177

174178

179+
def generate_report(template, jinja):
180+
if not os.path.isdir("report"):
181+
os.mkdir("report")
182+
183+
if not os.path.isdir("report/images"):
184+
os.mkdir("report/images")
185+
186+
with open("report/index.html", "w") as fh:
187+
data = template.render(jinja)
188+
fh.write(data)
189+
175190
if __name__ == "__main__":
176191
main()

0 commit comments

Comments
 (0)