Commit 2670fbe6 authored by Alberts S's avatar Alberts S
Browse files

Visualizer when doing pyvis, add factual optimization information

parent 44f8f35f
......@@ -18,6 +18,7 @@ class Visualizer(CapybaraNetty):
self.pinger_data = []
self.external_targets_for_optimizations = []
self.optimization_threshold_ms = 0
self.include_factual_weight = False
async def run(self):
G_simple = await self.get_host_latency_overview()
......@@ -74,7 +75,7 @@ class Visualizer(CapybaraNetty):
and path[-1] in self.external_targets_for_optimizations
):
optimized_ms = G[key][path[0]]["weight"] - lengths[key]
if optimized_ms < self.optimization_threshold_ms:
if optimized_ms <= self.optimization_threshold_ms:
self.__logger.debug(
f"VISUALIZER IGNORED OPTIMIZATION: {optimized_ms:<3d}ms {'->'.join(path[::-1])}"
)
......@@ -119,18 +120,22 @@ class Visualizer(CapybaraNetty):
async def draw_graphs(self, G: nx.Graph, file_base_name):
output_base_name = f'out/network_latency_{file_base_name}_{time.strftime("%Y%m%d-%H_%M_%S")}'
await self.draw_graph_networkx(G, output_base_name)
await self.draw_graph_pyvis(G, output_base_name)
await self.draw_graph_pyvis(G, output_base_name, include_dummy_weight=False)
await self.draw_graph_pyvis(G, output_base_name, include_dummy_weight=True)
async def draw_graph_pyvis(self, G, output_base):
async def draw_graph_pyvis(self, G, output_base, include_dummy_weight: bool):
# PyVis
net = Network("1280px", "1280px")
net.show_buttons(filter_=["physics"])
net.show_buttons(filter_=True)
net.from_nx(G)
net.barnes_hut(spring_length=250)
for edge in net.edges:
edge["label"] = edge["weight"]
if include_dummy_weight:
edge["label"] = f'{edge["weight"]} [{edge["weight_dummy"]}]'
else:
edge["label"] = f'{edge["weight"]}'
output_name = f"{output_base}_pyvis.html"
output_name = f"{output_base}_pyvis{'_with_dummy' if include_dummy_weight else ''}.html"
self.__logger.info(f"Writing {output_name}")
net.save_graph(output_name)
......@@ -154,5 +159,6 @@ class Visualizer(CapybaraNetty):
self.optimization_threshold_ms = self.config["optimization_threshold_ms"]
self.pinger_data = pinger_data_fn()
self.external_targets_for_optimizations = self.config["external_targets_for_optimizations"]
self.include_factual_weight = self.config["visualizer_include_factual_weight"]
await self.run()
await asyncio.sleep(self.config["visualizer_interval"])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment