MCPcopy Create free account
hub / github.com/It4innovations/hyperqueue / serve_summary_html

Function serve_summary_html

benchmarks/src/postprocessing/serve.py:46–205  ·  view source on GitHub ↗
(database: Database, directory: Path, port: int)

Source from the content-addressed store, hash-verified

44
45
46def serve_summary_html(database: Database, directory: Path, port: int):
47 entries = pregenerate_entries(database, directory)
48 io_loop = IOLoop.current()
49 img = io.BytesIO()
50
51 class SummaryHandler(web.RequestHandler):
52 def get(self):
53 page = create_summary_page(database, directory)
54 self.write(page)
55
56 class ClusterHandler(web.RequestHandler):
57 def get(self, key: str):
58 report = entries[str(Path(key).stem)].report
59 page = create_page(report)
60 self.write(file_html(page, CDN, "Cluster report"))
61
62 class ComparisonHandler(web.RequestHandler):
63 def get(self, key: str):
64 html_file = open(Path("summary/comparisons").joinpath(key), "r", encoding="utf-8")
65 source_code = html_file.read()
66 self.write(source_code)
67
68 class CompareOverview(web.RequestHandler):
69 def get(self, key: str):
70 df = create_database_df(database)
71 key = key.split("(")[1].split(")")[0]
72 df = df[df["workload-params"] == key]
73 max_index = df["index"].max()
74 samples = [df[df["index"] == i] for i in range(max_index + 1)]
75 tables = [i["duration"].describe().to_frame() for i in samples]
76 compare1 = tables[0] > tables[1]
77 compare0 = tables[1] > tables[0]
78
79 def color_0(x):
80 return ["background-color:red" if i[1][0] else "" for i in compare0.iterrows()]
81
82 def color_1(x):
83 return ["background-color:red" if i[1][0] else "" for i in compare1.iterrows()]
84
85 # tables[1].style.apply_index(color_b)
86 output = ""
87 tables[0].style.set_uuid("table0")
88 tables[1].style.set_uuid("table1")
89 output += tables[0].style.apply(color_0).set_uuid("table0").to_html()
90 output += tables[1].style.apply(color_1).set_uuid("table1").to_html()
91
92 plt.scatter(df["index"], df["duration"], s=10)
93 plt.xticks(list(range(max_index + 1)))
94 plt.ylabel("Duration [ms]")
95
96 plt.savefig(img, format="png")
97 plt.clf()
98
99 with open(os.path.join(os.path.dirname(__file__), "templates/compare_table.html")) as fp:
100 file = fp.read()
101
102 self.write(render(file, tables=output))
103

Callers 1

serve_htmlFunction · 0.90

Calls 3

pregenerate_entriesFunction · 0.85
infoMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected