Skip to content

Commit 40c3c0a

Browse files
change location of topology image
1 parent 2d3bf06 commit 40c3c0a

File tree

3 files changed

+7
-26
lines changed

3 files changed

+7
-26
lines changed

nebula/addons/topologymanager.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -169,43 +169,25 @@ def draw_graph(self, plot=False, path=None):
169169
None: The method saves the plot as an image at the specified path.
170170
"""
171171
g = nx.from_numpy_array(self.topology)
172-
# pos = nx.layout.spectral_layout(g)
173-
# pos = nx.spring_layout(g, pos=pos, iterations=50)
174172
pos = nx.spring_layout(g, k=0.15, iterations=20, seed=42)
175173

176174
fig = plt.figure(num="Network topology", dpi=100, figsize=(6, 6), frameon=False)
177175
ax = fig.add_axes([0, 0, 1, 1])
178176
ax.set_xlim([-1.3, 1.3])
179177
ax.set_ylim([-1.3, 1.3])
180-
# ax.axis('off')
181178
labels = {}
182179
color_map = []
183180
for k in range(self.n_nodes):
184181
role = str(self.nodes[k][2])
185182
color_map.append(self.get_node_color(role))
186183
labels[k] = f"P{k}\n" + str(self.nodes[k][0]) + ":" + str(self.nodes[k][1])
187184

188-
# nx.draw_networkx_nodes(g, pos_shadow, node_color='k', alpha=0.5)
189185
nx.draw_networkx_nodes(g, pos, node_color=color_map, linewidths=2)
190186
nx.draw_networkx_labels(g, pos, labels, font_size=10, font_weight="bold")
191187
nx.draw_networkx_edges(g, pos, width=2)
192-
# plt.margins(0.0)
193188

194189
self.add_legend([str(node[2]) for node in self.nodes])
195-
196-
# plt.scatter([], [], c="green", label='Central Server')
197-
# plt.scatter([], [], c="orange", label='Aggregator')
198-
# plt.scatter([], [], c="#6182bd", label='Trainer')
199-
# plt.scatter([], [], c="purple", label='Proxy')
200-
# plt.scatter([], [], c="red", label='Idle')
201-
# import sys
202-
# if path is None:
203-
# if not os.path.exists(f"{sys.path[0]}/logs/{self.scenario_name}"):
204-
# os.makedirs(f"{sys.path[0]}/logs/{self.scenario_name}")
205-
# plt.savefig(f"{sys.path[0]}/logs/{self.scenario_name}/topology.png", dpi=100, bbox_inches="tight", pad_inches=0)
206-
# else:
207190
plt.savefig(f"{path}", dpi=100, bbox_inches="tight", pad_inches=0)
208-
# plt.gcf().canvas.draw()
209191
plt.close()
210192

211193
def generate_topology(self):

nebula/frontend/app.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -733,12 +733,11 @@ def update_topology(scenario_name, nodes_list, nodes_config):
733733
matrix = np.zeros((len(nodes), len(nodes)))
734734
for node in nodes_list:
735735
for neighbour in node[5].split(" "):
736-
if neighbour != "":
737-
if neighbour in nodes:
738-
matrix[
739-
nodes.index(node[2] + ":" + str(node[3])),
740-
nodes.index(neighbour),
741-
] = 1
736+
if neighbour != "" and neighbour in nodes:
737+
matrix[
738+
nodes.index(node[2] + ":" + str(node[3])),
739+
nodes.index(neighbour),
740+
] = 1
742741
from nebula.addons.topologymanager import TopologyManager
743742

744743
tm = TopologyManager(n_nodes=len(nodes_list), topology=matrix, scenario_name=scenario_name)
@@ -916,7 +915,7 @@ async def nebula_monitor_log_error(scenario_name: str, id: str):
916915

917916
@app.get("/platform/dashboard/{scenario_name}/topology/image/")
918917
async def nebula_monitor_image(scenario_name: str):
919-
topology_image = FileUtils.check_path(settings.log_dir, os.path.join(scenario_name, "topology.png"))
918+
topology_image = FileUtils.check_path(settings.config_dir, os.path.join(scenario_name, "topology.png"))
920919
if os.path.exists(topology_image):
921920
return FileResponse(topology_image, media_type="image/png")
922921
else:

nebula/scenarios.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ def load_configurations_and_start_nodes(self, additional_participants=None, sche
524524

525525
# Add role to the topology (visualization purposes)
526526
self.topologymanager.update_nodes(config_participants)
527-
self.topologymanager.draw_graph(path=f"{self.log_dir}/{self.scenario_name}/topology.png", plot=False)
527+
self.topologymanager.draw_graph(path=f"{self.config_dir}/topology.png", plot=False)
528528

529529
# Include additional participants (if any) as copies of the last participant
530530
additional_participants_files = []

0 commit comments

Comments
 (0)