Commit 0e82b6a1 authored by Alberts S's avatar Alberts S
Browse files

Fixup Visualizer

parent 60508338
......@@ -26,10 +26,14 @@ class Visualizer(CapybaraNetty):
G_optimizations = await self.get_host_latency_optimization_overview(G_simple.copy())
await self.draw_graphs(self.get_graph_only_improved_overview(G_optimizations), "optimizations_overview")
for target in self.external_targets_for_optimizations:
await self.draw_graphs(
self.get_graph_only_improved_specific_target(G_optimizations, target),
f"optimizations_target_{target}",
)
target_filtered_graph = self.get_graph_only_improved_specific_target(G_optimizations, target)
if target_filtered_graph.number_of_nodes() > 0:
await self.draw_graphs(
target_filtered_graph,
f"optimizations_target_{target}",
)
else:
self.__logger.debug(f"Not drawing graph for {target=} since the filtered graph is empty")
else:
self.__logger.warning("Doing nothing since G is empty")
......@@ -39,7 +43,14 @@ class Visualizer(CapybaraNetty):
host = result["from_name"]
dest = result["to_name"]
time = int(result["time"])
G.add_edge(host, dest, weight=time, color="black")
result_kind = result["result_kind"]
if result_kind == "external":
attrs = {
"weight": time,
}
else:
attrs = {f"weight_{result_kind}": time}
G.add_edge(host, dest, **attrs, color="black")
G.nodes[host]["type"] = result["from_type"]
G.nodes[dest]["type"] = result["to_type"]
return G
......@@ -60,11 +71,13 @@ class Visualizer(CapybaraNetty):
for key, path in paths.items():
if len(path) > 2 and not (
path[0] in self.external_targets_for_optimizations
or path[-1] in self.external_targets_for_optimizations
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:
self.__logger.debug(f"IGNORED OPTIMIZATION: {optimized_ms:<3d}ms {'->'.join(path[::-1])}")
self.__logger.debug(
f"VISUALIZER IGNORED OPTIMIZATION: {optimized_ms:<3d}ms {'->'.join(path[::-1])}"
)
else:
color = palette[palette_index]
palette_index += 1
......@@ -79,7 +92,9 @@ class Visualizer(CapybaraNetty):
G.nodes[node]["improved_path"] = True
G.nodes[node].setdefault("improved_path_targets", []).append(target)
self.__logger.info(f"VIABLE OPTIMIZATION: {optimized_ms:<3d}ms {'->'.join(path[::-1])}")
self.__logger.info(
f"VISUALIZER VIABLE OPTIMIZATION: {optimized_ms:<3d}ms {'->'.join(path[::-1])}"
)
return G
def get_graph_only_improved_overview(self, G: nx.Graph):
......
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