← back to Exo
pass origin_node_id to merge
657520ed4c9abfedcf8a4e4dec80e567c190ee7a · 2024-12-05 22:31:21 +0000 · Alex Cheema
Files touched
M exo/orchestration/standard_node.pyM exo/topology/topology.py
Diff
commit 657520ed4c9abfedcf8a4e4dec80e567c190ee7a
Author: Alex Cheema <alexcheema123@gmail.com>
Date: Thu Dec 5 22:31:21 2024 +0000
pass origin_node_id to merge
---
exo/orchestration/standard_node.py | 2 +-
exo/topology/topology.py | 9 +++++----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/exo/orchestration/standard_node.py b/exo/orchestration/standard_node.py
index 310f18f6..b88b1722 100644
--- a/exo/orchestration/standard_node.py
+++ b/exo/orchestration/standard_node.py
@@ -410,7 +410,7 @@ class StandardNode(Node):
try:
other_topology = await asyncio.wait_for(peer.collect_topology(visited, max_depth=max_depth - 1), timeout=5.0)
if DEBUG >= 2: print(f"Collected topology from: {peer.id()}: {other_topology}")
- next_topology.merge(other_topology)
+ next_topology.merge(self.id, other_topology)
except Exception as e:
print(f"Error collecting topology from {peer.id()}: {e}")
traceback.print_exc()
diff --git a/exo/topology/topology.py b/exo/topology/topology.py
index b966f7f1..6040369f 100644
--- a/exo/topology/topology.py
+++ b/exo/topology/topology.py
@@ -21,7 +21,6 @@ class PeerConnection:
class Topology:
def __init__(self):
self.nodes: Dict[str, DeviceCapabilities] = {}
- # Store PeerConnection objects in the adjacency lists
self.peer_graph: Dict[str, Set[PeerConnection]] = {}
self.active_node_id: Optional[str] = None
@@ -40,12 +39,14 @@ class Topology:
conn = PeerConnection(from_id, to_id, description)
self.peer_graph[from_id].add(conn)
- def merge(self, other: "Topology"):
+ def merge(self, origin_node_id: str, other: "Topology"):
for node_id, capabilities in other.nodes.items():
- self.update_node(node_id, capabilities)
+ if node_id != origin_node_id:
+ self.update_node(node_id, capabilities)
for node_id, connections in other.peer_graph.items():
for conn in connections:
- self.add_edge(conn.from_id, conn.to_id, conn.description)
+ if conn.from_id != origin_node_id:
+ self.add_edge(conn.from_id, conn.to_id, conn.description)
def __str__(self):
nodes_str = ", ".join(f"{node_id}: {cap}" for node_id, cap in self.nodes.items())
← 81632247 coll
·
back to Exo
·
consistnet self.topology 0b9ee8ab →