Skip to content

Commit

Permalink
Merge pull request #533 from SpiNNakerManchester/roc_part
Browse files Browse the repository at this point in the history
fixes for FrontEndCommon typing
  • Loading branch information
Christian-B committed Nov 10, 2023
2 parents d49ffca + 6c17237 commit b9c1c42
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 22 deletions.
9 changes: 8 additions & 1 deletion pacman/model/graphs/abstract_vertex.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def set_label(self, label: str):
"As Labels are also IDs they can not be changed.")
self._label = label

def addedToGraph(self) -> None:
def setAddedToGraph(self) -> None:
"""
Records that the vertex has been added to a graph.
Expand All @@ -71,6 +71,13 @@ def addedToGraph(self) -> None:
"""
self._added_to_graph = True

def has_been_added_to_graph(self) -> bool:
"""
State if the vertex has been added to the graph or not
"""
return self._added_to_graph

def get_fixed_location(self) -> Optional[ChipAndCore]:
"""
The x, y and possibly p the vertex *must* be placed on.
Expand Down
2 changes: 1 addition & 1 deletion pacman/model/graphs/application/application_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def add_vertex(self, vertex: ApplicationVertex):
if self._vertex_by_label[vertex.label] == vertex:
raise PacmanAlreadyExistsException("vertex", vertex.label)
vertex.set_label(vertex.label + self._label_postfix())
vertex.addedToGraph()
vertex.setAddedToGraph()
self._vertex_by_label[cast(str, vertex.label)] = vertex

@property
Expand Down
14 changes: 14 additions & 0 deletions pacman/model/routing_tables/abstract_multicast_routing_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ def multicast_routing_entries(self) -> Collection[MulticastRoutingEntry]:
"""
raise NotImplementedError

@abstractmethod
def add_multicast_routing_entry(
self, multicast_routing_entry: MulticastRoutingEntry):
"""
Adds a routing entry to this table.
:param ~spinn_machine.MulticastRoutingEntry multicast_routing_entry:
The route to add
:raise PacmanAlreadyExistsException:
If a routing entry with the same key-mask combination already
exists
"""
raise NotImplementedError

@property
@abstractmethod
def number_of_entries(self) -> int:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,9 @@ def __init__(
for multicast_routing_entry in multicast_routing_entries:
self.add_multicast_routing_entry(multicast_routing_entry)

@overrides(AbstractMulticastRoutingTable.add_multicast_routing_entry)
def add_multicast_routing_entry(
self, multicast_routing_entry: MulticastRoutingEntry):
"""
Adds a routing entry to this table.
:param ~spinn_machine.MulticastRoutingEntry multicast_routing_entry:
The route to add
:raise pacman.exceptions.PacmanAlreadyExistsException: If a routing
entry with the same key-mask combination already exists
"""
self._multicast_routing_entries.append(multicast_routing_entry)

# update default routed counter if required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,9 @@ def __init__(
for multicast_routing_entry in multicast_routing_entries:
self.add_multicast_routing_entry(multicast_routing_entry)

@overrides(AbstractMulticastRoutingTable.add_multicast_routing_entry)
def add_multicast_routing_entry(
self, multicast_routing_entry: MulticastRoutingEntry):
"""
Adds a routing entry to this table.
:param ~spinn_machine.MulticastRoutingEntry multicast_routing_entry:
The route to add
:raise PacmanAlreadyExistsException:
If a routing entry with the same key-mask combination already
exists
"""
routing_entry_key = multicast_routing_entry.routing_entry_key
mask = multicast_routing_entry.mask

Expand Down
5 changes: 3 additions & 2 deletions pacman/operations/fixed_route_router/fixed_route_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
PacmanRoutingException)


def fixed_route_router(destination_class):
def fixed_route_router(
destination_class) -> Dict[Tuple[int, int], FixedRouteEntry]:
"""
Runs the fixed route generator for all boards on machine.
:param destination_class: the destination class to route packets to
:type destination_class: type or tuple(type,...)
:return: router tables for fixed route paths
:rtype: dict(~spinn_machine.Chip, ~spinn_machine.FixedRouteEntry)
:rtype: dict((int, int)), ~spinn_machine.FixedRouteEntry)
:raises PacmanConfigurationException: if no placement processor found
:raises PacmanRoutingException:
:raises PacmanAlreadyExistsException:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ def test_set_label(self):
vert = SimpleTestVertex(5)
vert.set_label("test 1")
self.assertEqual("test 1", vert.label)
vert.addedToGraph()
self.assertFalse(vert.has_been_added_to_graph())
vert.setAddedToGraph()
with self.assertRaises(PacmanConfigurationException):
vert.set_label("test 2")
self.assertTrue(vert.has_been_added_to_graph())

0 comments on commit b9c1c42

Please sign in to comment.