From e596a366c33e6a1d99b9c93db5433e5836b6ed0e Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 21 Dec 2023 08:02:54 +0000 Subject: [PATCH 01/16] type overrides --- spinnaker_graph_front_end/utilities/simulator_vertex.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spinnaker_graph_front_end/utilities/simulator_vertex.py b/spinnaker_graph_front_end/utilities/simulator_vertex.py index 1454a4e6..246d9bf3 100644 --- a/spinnaker_graph_front_end/utilities/simulator_vertex.py +++ b/spinnaker_graph_front_end/utilities/simulator_vertex.py @@ -56,11 +56,11 @@ def __init__(self, label, binary_name, vertex_slice=None): self.__front_end = sys.modules["spinnaker_graph_front_end"] @overrides(AbstractHasAssociatedBinary.get_binary_file_name) - def get_binary_file_name(self): + def get_binary_file_name(self) -> str: return self._binary_name @overrides(AbstractHasAssociatedBinary.get_binary_start_type) - def get_binary_start_type(self): + def get_binary_start_type(self) -> ExecutableType: return ExecutableType.USES_SIMULATION_INTERFACE @property From fcf3dce8248cb39464b73f162f8d3085575b5216 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 21 Dec 2023 16:18:24 +0000 Subject: [PATCH 02/16] override typing --- .../conways_basic_cell.py | 10 +++- .../conways_basic_cell.py | 14 +++-- .../hello_world/hello_world_vertex.py | 14 +++-- .../hello_world_untimed/hello_world_vertex.py | 12 ++-- gfe_examples/live_io/live_io_vertex.py | 10 +++- gfe_examples/sync_test/sync_test_vertex.py | 11 ++-- gfe_examples/template/template_vertex.py | 14 +++-- .../common/sdram_machine_vertex.py | 19 ++++--- .../sdram_splitter_internal.py | 55 +++++++++++-------- .../sdram_splitter.py | 55 ++++++++++++------- .../test_multi_src_internal/sdram_splitter.py | 51 ++++++++++------- .../test_extra_monitor/sdram_writer.py | 8 ++- .../test_profile/profiled_vertex.py | 15 +++-- .../utilities/simulator_vertex.py | 6 +- 14 files changed, 189 insertions(+), 105 deletions(-) diff --git a/gfe_examples/Conways/partitioned_example_a_no_vis_no_buffer/conways_basic_cell.py b/gfe_examples/Conways/partitioned_example_a_no_vis_no_buffer/conways_basic_cell.py index 477674b7..53f5c23e 100644 --- a/gfe_examples/Conways/partitioned_example_a_no_vis_no_buffer/conways_basic_cell.py +++ b/gfe_examples/Conways/partitioned_example_a_no_vis_no_buffer/conways_basic_cell.py @@ -13,10 +13,14 @@ # limitations under the License. from enum import IntEnum +from typing import Iterable, Optional from spinn_utilities.overrides import overrides +from spinn_machine.tags import IPTag, ReverseIPTag from pacman.model.graphs.machine import MachineVertex +from pacman.model.placements import Placement from pacman.model.resources import VariableSDRAM from spinn_front_end_common.data import FecDataView +from spinn_front_end_common.interface.ds import DataSpecificationGenerator from spinn_front_end_common.utilities.constants import ( SYSTEM_BYTES_REQUIREMENT, BYTES_PER_WORD) from spinn_front_end_common.utilities.exceptions import ConfigurationException @@ -72,7 +76,9 @@ def add_neighbour(self, neighbour): @overrides( MachineDataSpecableVertex.generate_machine_data_specification) def generate_machine_data_specification( - self, spec, placement, iptags, reverse_iptags): + self, spec: DataSpecificationGenerator, placement: Placement, + iptags: Optional[Iterable[IPTag]], + reverse_iptags: Optional[Iterable[ReverseIPTag]]): if len(self._neighbours) != 8: raise ValueError( f"Only {len(self._neighbours)} neighbours, not 8") @@ -149,7 +155,7 @@ def get_data(self): @property @overrides(MachineVertex.sdram_required) - def sdram_required(self): + def sdram_required(self) -> VariableSDRAM: fixed_sdram = (SYSTEM_BYTES_REQUIREMENT + self.TRANSMISSION_DATA_SIZE + self.STATE_DATA_SIZE + self.NEIGHBOUR_INITIAL_STATES_SIZE + diff --git a/gfe_examples/Conways/partitioned_example_b_no_vis_buffer/conways_basic_cell.py b/gfe_examples/Conways/partitioned_example_b_no_vis_buffer/conways_basic_cell.py index 4d7cfc71..98c0aa71 100644 --- a/gfe_examples/Conways/partitioned_example_b_no_vis_buffer/conways_basic_cell.py +++ b/gfe_examples/Conways/partitioned_example_b_no_vis_buffer/conways_basic_cell.py @@ -13,10 +13,14 @@ # limitations under the License. from enum import IntEnum +from typing import Iterable, List, Optional from spinn_utilities.overrides import overrides +from spinn_machine.tags import IPTag, ReverseIPTag from pacman.model.graphs.machine import MachineVertex +from pacman.model.placements import Placement from pacman.model.resources import VariableSDRAM from spinn_front_end_common.data import FecDataView +from spinn_front_end_common.interface.ds import DataSpecificationGenerator from spinn_front_end_common.utilities.constants import ( SYSTEM_BYTES_REQUIREMENT, BYTES_PER_WORD) from spinn_front_end_common.utilities.helpful_functions import ( @@ -80,7 +84,9 @@ def add_neighbour(self, neighbour): @overrides(MachineDataSpecableVertex.generate_machine_data_specification) def generate_machine_data_specification( - self, spec, placement, iptags, reverse_iptags): + self, spec: DataSpecificationGenerator, placement: Placement, + iptags: Optional[Iterable[IPTag]], + reverse_iptags: Optional[Iterable[ReverseIPTag]]): # pylint: disable=arguments-differ if len(self._neighbours) != 8: raise ValueError( @@ -147,7 +153,7 @@ def get_data(self): @property @overrides(MachineVertex.sdram_required) - def sdram_required(self): + def sdram_required(self) -> VariableSDRAM: fixed_sdram = ( SYSTEM_BYTES_REQUIREMENT + self.TRANSMISSION_DATA_SIZE + @@ -166,10 +172,10 @@ def __repr__(self): return self.label @overrides(AbstractReceiveBuffersToHost.get_recorded_region_ids) - def get_recorded_region_ids(self): + def get_recorded_region_ids(self) -> List[int]: return [Channels.STATE_LOG] @overrides(AbstractReceiveBuffersToHost.get_recording_region_base_address) - def get_recording_region_base_address(self, placement): + def get_recording_region_base_address(self, placement) -> int: return locate_memory_region_for_placement( placement, DataRegions.RESULTS) diff --git a/gfe_examples/hello_world/hello_world_vertex.py b/gfe_examples/hello_world/hello_world_vertex.py index accfb261..1e977926 100644 --- a/gfe_examples/hello_world/hello_world_vertex.py +++ b/gfe_examples/hello_world/hello_world_vertex.py @@ -14,10 +14,14 @@ from enum import IntEnum import logging +from typing import Iterable, List, Optional from spinn_utilities.log import FormatAdapter from spinn_utilities.overrides import overrides +from spinn_machine.tags import IPTag, ReverseIPTag from pacman.model.graphs.machine import MachineVertex +from pacman.model.placements import Placement from pacman.model.resources import ConstantSDRAM +from spinn_front_end_common.interface.ds import DataSpecificationGenerator from spinn_front_end_common.utilities.constants import SYSTEM_BYTES_REQUIREMENT from spinn_front_end_common.utilities.helpful_functions import ( locate_memory_region_for_placement) @@ -53,7 +57,7 @@ def __init__(self, n_hellos, label=None): @property @overrides(MachineVertex.sdram_required) - def sdram_required(self): + def sdram_required(self) -> ConstantSDRAM: return ConstantSDRAM( SYSTEM_BYTES_REQUIREMENT + get_recording_header_size(len(Channels)) + @@ -61,7 +65,9 @@ def sdram_required(self): @overrides(MachineDataSpecableVertex.generate_machine_data_specification) def generate_machine_data_specification( - self, spec, placement, iptags, reverse_iptags): + self, spec: DataSpecificationGenerator, placement: Placement, + iptags: Optional[Iterable[IPTag]], + reverse_iptags: Optional[Iterable[ReverseIPTag]]): # Generate the system data region for simulation .c requirements self.generate_system_region(spec) @@ -84,10 +90,10 @@ def read(self): return str(bytearray(raw_data)) @overrides(AbstractReceiveBuffersToHost.get_recorded_region_ids) - def get_recorded_region_ids(self): + def get_recorded_region_ids(self) -> List[int]: return [Channels.HELLO] @overrides(AbstractReceiveBuffersToHost.get_recording_region_base_address) - def get_recording_region_base_address(self, placement): + def get_recording_region_base_address(self, placement) -> int: return locate_memory_region_for_placement( placement, DataRegions.STRING_DATA) diff --git a/gfe_examples/hello_world_untimed/hello_world_vertex.py b/gfe_examples/hello_world_untimed/hello_world_vertex.py index 4453829d..3fd41e88 100644 --- a/gfe_examples/hello_world_untimed/hello_world_vertex.py +++ b/gfe_examples/hello_world_untimed/hello_world_vertex.py @@ -14,9 +14,11 @@ from enum import IntEnum import logging +from typing import List from spinn_utilities.log import FormatAdapter from spinn_utilities.overrides import overrides from pacman.model.graphs.machine import MachineVertex +from pacman.model.placements import Placement from pacman.model.resources import VariableSDRAM from spinn_front_end_common.data import FecDataView from spinn_front_end_common.utilities.constants import ( @@ -29,6 +31,7 @@ AbstractReceiveBuffersToHost) from spinn_front_end_common.interface.buffer_management import ( recording_utilities) +from spinn_front_end_common.interface.ds import DataSpecificationGenerator from spinnaker_graph_front_end.utilities import SimulatorVertex from spinnaker_graph_front_end.utilities.data_utils import ( generate_steps_system_data_region) @@ -76,7 +79,7 @@ def __init__(self, label): @property @overrides(MachineVertex.sdram_required) - def sdram_required(self): + def sdram_required(self) -> VariableSDRAM: fixed = ( SYSTEM_BYTES_REQUIREMENT + recording_utilities.get_recording_header_size(len(Channels)) + @@ -85,7 +88,8 @@ def sdram_required(self): return VariableSDRAM(fixed, variable) @overrides(AbstractGeneratesDataSpecification.generate_data_specification) - def generate_data_specification(self, spec, placement): + def generate_data_specification( + self, spec: DataSpecificationGenerator, placement: Placement): # pylint: disable=arguments-differ # Generate the system data region for simulation .c requirements @@ -124,10 +128,10 @@ def read(self): return str(raw_data, self._ENCODING) @overrides(AbstractReceiveBuffersToHost.get_recorded_region_ids) - def get_recorded_region_ids(self): + def get_recorded_region_ids(self) -> List[int]: return [Channels.HELLO] @overrides(AbstractReceiveBuffersToHost.get_recording_region_base_address) - def get_recording_region_base_address(self, placement): + def get_recording_region_base_address(self, placement: Placement) -> int: return locate_memory_region_for_placement( placement, DataRegions.STRING_DATA) diff --git a/gfe_examples/live_io/live_io_vertex.py b/gfe_examples/live_io/live_io_vertex.py index ee9e49e5..42bf4fa9 100644 --- a/gfe_examples/live_io/live_io_vertex.py +++ b/gfe_examples/live_io/live_io_vertex.py @@ -14,11 +14,15 @@ from enum import IntEnum import logging +from typing import Iterable, Optional from spinn_utilities.log import FormatAdapter from spinn_utilities.overrides import overrides +from spinn_machine.tags import IPTag, ReverseIPTag from pacman.model.graphs.common import Slice from pacman.model.graphs.machine import MachineVertex +from pacman.model.placements import Placement from pacman.model.resources import ConstantSDRAM +from spinn_front_end_common.interface.ds import DataSpecificationGenerator from spinn_front_end_common.utilities.constants import ( SYSTEM_BYTES_REQUIREMENT, BYTES_PER_WORD) from spinn_front_end_common.abstract_models.impl import ( @@ -46,7 +50,7 @@ def __init__(self, n_keys, send_partition="LiveOut", label=None): @property @overrides(MachineVertex.sdram_required) - def sdram_required(self): + def sdram_required(self) -> ConstantSDRAM: return ConstantSDRAM( SYSTEM_BYTES_REQUIREMENT + N_KEY_DATA_BYTES) @@ -55,7 +59,9 @@ def get_n_keys_for_partition(self, partition_id): @overrides(MachineDataSpecableVertex.generate_machine_data_specification) def generate_machine_data_specification( - self, spec, placement, iptags, reverse_iptags): + self, spec: DataSpecificationGenerator, placement: Placement, + iptags: Optional[Iterable[IPTag]], + reverse_iptags: Optional[Iterable[ReverseIPTag]]): # Generate the system data region for simulation .c requirements self.generate_system_region(spec) diff --git a/gfe_examples/sync_test/sync_test_vertex.py b/gfe_examples/sync_test/sync_test_vertex.py index 3dfabaaa..13bf8de5 100644 --- a/gfe_examples/sync_test/sync_test_vertex.py +++ b/gfe_examples/sync_test/sync_test_vertex.py @@ -18,8 +18,10 @@ from spinn_utilities.overrides import overrides from spinnman.model.enums import ExecutableType from pacman.model.graphs.machine import MachineVertex +from pacman.model.placements import Placement from pacman.model.resources import ConstantSDRAM from spinn_front_end_common.data import FecDataView +from spinn_front_end_common.interface.ds import DataSpecificationGenerator from spinn_front_end_common.utilities.constants import ( SYSTEM_BYTES_REQUIREMENT, BYTES_PER_WORD) from spinn_front_end_common.abstract_models import ( @@ -54,21 +56,22 @@ def __init__(self, lead, app_vertex, label=None): self._lead = lead @overrides(AbstractHasAssociatedBinary.get_binary_file_name) - def get_binary_file_name(self): + def get_binary_file_name(self) -> str: return "sync_test.aplx" @overrides(AbstractHasAssociatedBinary.get_binary_start_type) - def get_binary_start_type(self): + def get_binary_start_type(self) -> ExecutableType: return ExecutableType.USES_SIMULATION_INTERFACE @property @overrides(MachineVertex.sdram_required) - def sdram_required(self): + def sdram_required(self) -> ConstantSDRAM: return ConstantSDRAM(SYSTEM_BYTES_REQUIREMENT + BYTES_PER_WORD * 2) @overrides( AbstractGeneratesDataSpecification.generate_data_specification) - def generate_data_specification(self, spec, placement): + def generate_data_specification( + self, spec: DataSpecificationGenerator, placement: Placement): # Generate the system data region for simulation .c requirements generate_system_data_region(spec, DataRegions.SYSTEM.value, self) diff --git a/gfe_examples/template/template_vertex.py b/gfe_examples/template/template_vertex.py index 61d82695..c23070c1 100644 --- a/gfe_examples/template/template_vertex.py +++ b/gfe_examples/template/template_vertex.py @@ -14,11 +14,15 @@ from enum import IntEnum import logging +from typing import Iterable, List, Optional from spinn_utilities.log import FormatAdapter from spinn_utilities.overrides import overrides +from spinn_machine.tags import IPTag, ReverseIPTag from pacman.model.graphs.machine import MachineVertex +from pacman.model.placements import Placement from pacman.model.resources import VariableSDRAM from spinn_front_end_common.data import FecDataView +from spinn_front_end_common.interface.ds import DataSpecificationGenerator from spinn_front_end_common.utilities.constants import ( SYSTEM_BYTES_REQUIREMENT, BYTES_PER_WORD) from spinn_front_end_common.utilities.helpful_functions import ( @@ -68,7 +72,7 @@ def __init__(self, label): @property @overrides(MachineVertex.sdram_required) - def sdram_required(self): + def sdram_required(self) -> VariableSDRAM: constant_sdram = ( SYSTEM_BYTES_REQUIREMENT + self.TRANSMISSION_REGION_N_BYTES + recording_utilities.get_recording_header_size( @@ -82,7 +86,9 @@ def sdram_required(self): @overrides(MachineDataSpecableVertex.generate_machine_data_specification) def generate_machine_data_specification( - self, spec, placement, iptags, reverse_iptags): + self, spec: DataSpecificationGenerator, placement: Placement, + iptags: Optional[Iterable[IPTag]], + reverse_iptags: Optional[Iterable[ReverseIPTag]]): # Generate the system data region for simulation .c requirements self.generate_system_region(spec, DataRegions.SYSTEM) @@ -125,10 +131,10 @@ def read(self): return raw_data @overrides(AbstractReceiveBuffersToHost.get_recorded_region_ids) - def get_recorded_region_ids(self): + def get_recorded_region_ids(self) -> List[int]: return [RecordingChannels.RECORDING] @overrides(AbstractReceiveBuffersToHost.get_recording_region_base_address) - def get_recording_region_base_address(self, placement): + def get_recording_region_base_address(self, placement: Placement) -> int: return locate_memory_region_for_placement( placement, DataRegions.RECORDED_DATA) diff --git a/gfe_integration_tests/sdram_edge_tests/common/sdram_machine_vertex.py b/gfe_integration_tests/sdram_edge_tests/common/sdram_machine_vertex.py index 9ebdeb63..ec1f9ab9 100644 --- a/gfe_integration_tests/sdram_edge_tests/common/sdram_machine_vertex.py +++ b/gfe_integration_tests/sdram_edge_tests/common/sdram_machine_vertex.py @@ -12,14 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. from enum import IntEnum - +from typing import Iterable, Optional from spinnman.model.enums import ExecutableType +from spinn_machine.tags import IPTag, ReverseIPTag from pacman.model.graphs import AbstractSupportsSDRAMEdges -from pacman.model.graphs.machine import MachineVertex +from pacman.model.graphs.machine import MachineVertex, SDRAMMachineEdge +from pacman.model.placements import Placement from pacman.model.resources import ConstantSDRAM from spinn_front_end_common.abstract_models import AbstractHasAssociatedBinary from spinn_front_end_common.abstract_models.impl import ( MachineDataSpecableVertex) +from spinn_front_end_common.interface.ds import DataSpecificationGenerator from spinn_front_end_common.interface.simulation import simulation_utilities from spinn_front_end_common.utilities.constants import ( SIMULATION_N_BYTES, BYTES_PER_WORD, SARK_PER_MALLOC_SDRAM_USAGE) @@ -60,7 +63,7 @@ def add_outgoing_sdram_partition(self, partition): @overrides(MachineVertex.sdram_required) - def sdram_required(self): + def sdram_required(self) -> ConstantSDRAM: if (len(self.__incoming_sdram_partitions) + len(self.__outgoing_sdram_partitions) == 0): raise ValueError("Isolated SDRAM vertex!") @@ -79,7 +82,7 @@ def sdram_required(self): outgoing_sdram_requirements) @overrides(AbstractSupportsSDRAMEdges.sdram_requirement) - def sdram_requirement(self, sdram_machine_edge): + def sdram_requirement(self, sdram_machine_edge: SDRAMMachineEdge) -> int: if self.__sdram_cost is None: raise NotImplementedError( "This vertex has no cost so is not expected to appear " @@ -87,16 +90,18 @@ def sdram_requirement(self, sdram_machine_edge): return self.__sdram_cost @overrides(AbstractHasAssociatedBinary.get_binary_file_name) - def get_binary_file_name(self): + def get_binary_file_name(self) -> str: return "sdram.aplx" @overrides(AbstractHasAssociatedBinary.get_binary_start_type) - def get_binary_start_type(self): + def get_binary_start_type(self) -> ExecutableType: return ExecutableType.USES_SIMULATION_INTERFACE @overrides(MachineDataSpecableVertex.generate_machine_data_specification) def generate_machine_data_specification( - self, spec, placement, iptags, reverse_iptags): + self, spec: DataSpecificationGenerator, placement: Placement, + iptags: Optional[Iterable[IPTag]], + reverse_iptags: Optional[Iterable[ReverseIPTag]]): # reserve memory regions spec.reserve_memory_region( region=DataRegions.SYSTEM, size=SIMULATION_N_BYTES, diff --git a/gfe_integration_tests/sdram_edge_tests/test_constant_internal/sdram_splitter_internal.py b/gfe_integration_tests/sdram_edge_tests/test_constant_internal/sdram_splitter_internal.py index a9482b88..94efa3c9 100644 --- a/gfe_integration_tests/sdram_edge_tests/test_constant_internal/sdram_splitter_internal.py +++ b/gfe_integration_tests/sdram_edge_tests/test_constant_internal/sdram_splitter_internal.py @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from typing import List from spinn_utilities.overrides import overrides from pacman.model.graphs.common import Slice from pacman.model.graphs.machine import SDRAMMachineEdge @@ -25,45 +26,48 @@ class SDRAMSplitterInternal(AbstractSplitterCommon): """ __slots__ = [ - "_partition_type", - "_pre_vertex", - "_pre_slice", - "_post_slice", - "_post_vertex", - "_app_edge", + "__pre_vertex", + "__post_vertex", "_sdram_part"] def __init__(self): super().__init__() - self._pre_vertex = None - self._post_vertex = None - self._pre_slice = None - self._post_slice = None - self._app_edge = None + self.__pre_vertex = None + self.__post_vertex = None self._sdram_part = None + @property + def _pre_vertex(self) -> SDRAMMachineVertex: + assert isinstance(self.__pre_vertex, SDRAMMachineVertex) + return self.__pre_vertex + + @property + def _post_vertex(self): + assert isinstance(self.__post_vertex, SDRAMMachineVertex) + return self.__post_vertex + @overrides(AbstractSplitterCommon.get_out_going_vertices) - def get_out_going_vertices(self, partition_id): + def get_out_going_vertices(self, partition_id) -> List[SDRAMMachineVertex]: return [self._pre_vertex] @overrides(AbstractSplitterCommon.get_in_coming_vertices) - def get_in_coming_vertices(self, partition_id): + def get_in_coming_vertices(self, partition_id) -> list[SDRAMMachineVertex]: return [self._post_vertex] def create_machine_vertices(self, chip_counter): # slices - self._pre_slice = Slice(0, int(self.governed_app_vertex.n_atoms / 2)) - self._post_slice = Slice( + pre_slice = Slice(0, int(self.governed_app_vertex.n_atoms / 2)) + post_slice = Slice( int(self.governed_app_vertex.n_atoms / 2) + 1, int(self.governed_app_vertex.n_atoms - 1)) # mac verts - self._pre_vertex = SDRAMMachineVertex( - vertex_slice=self._pre_slice, label=None, + self.__pre_vertex = SDRAMMachineVertex( + vertex_slice=pre_slice, label=None, app_vertex=self.governed_app_vertex, sdram_cost=20) self.governed_app_vertex.remember_machine_vertex(self._pre_vertex) - self._post_vertex = SDRAMMachineVertex( - vertex_slice=self._post_slice, label=None, + self.__post_vertex = SDRAMMachineVertex( + vertex_slice=post_slice, label=None, app_vertex=self.governed_app_vertex) self.governed_app_vertex.remember_machine_vertex(self._post_vertex) @@ -78,21 +82,24 @@ def create_machine_vertices(self, chip_counter): chip_counter.add_core(self._post_vertex.sdram_required) @overrides(AbstractSplitterCommon.get_out_going_slices) - def get_out_going_slices(self): + def get_out_going_slices(self) -> List[Slice]: return [self._post_vertex.vertex_slice] @overrides(AbstractSplitterCommon.get_in_coming_slices) - def get_in_coming_slices(self): + def get_in_coming_slices(self) -> List[Slice]: return [self._pre_vertex.vertex_slice] @overrides(AbstractSplitterCommon.machine_vertices_for_recording) - def machine_vertices_for_recording(self, variable_to_record): + def machine_vertices_for_recording( + self, variable_to_record: str) -> List[SDRAMMachineVertex]: return [self._pre_vertex, self._post_vertex] @overrides(AbstractSplitterCommon.reset_called) - def reset_called(self): + def reset_called(self) -> None: pass @overrides(AbstractSplitterCommon.get_internal_sdram_partitions) - def get_internal_sdram_partitions(self): + def get_internal_sdram_partitions( + self) -> List[ConstantSDRAMMachinePartition]: + assert isinstance(self._sdram_part, ConstantSDRAMMachinePartition) return [self._sdram_part] diff --git a/gfe_integration_tests/sdram_edge_tests/test_multi_dest_internal/sdram_splitter.py b/gfe_integration_tests/sdram_edge_tests/test_multi_dest_internal/sdram_splitter.py index a1f7c1c6..5ad9d3b0 100644 --- a/gfe_integration_tests/sdram_edge_tests/test_multi_dest_internal/sdram_splitter.py +++ b/gfe_integration_tests/sdram_edge_tests/test_multi_dest_internal/sdram_splitter.py @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from typing import List from spinn_utilities.overrides import overrides from pacman.model.graphs.common import Slice from pacman.model.graphs.machine import ( @@ -26,44 +27,51 @@ class SDRAMSplitter(AbstractSplitterCommon): N_VERTS = 3 __slots__ = [ - "_pre_vertex", - "_pre_slice", - "_post_slices", + "__pre_vertex", "_post_vertices", "_partition"] def __init__(self): super().__init__() - self._pre_vertex = None - self._post_vertices = list() - self._pre_slice = None - self._post_slices = list() + self.__pre_vertex = None + self._post_vertices: list[SDRAMMachineVertex] = list() + + @property + def _pre_vertex(self) -> SDRAMMachineVertex: + assert isinstance(self.__pre_vertex, SDRAMMachineVertex) + return self.__pre_vertex + + @property + def __post_vertex(self): + assert isinstance(self.__post_vertex, SDRAMMachineVertex) + return self.__post_vertex @overrides(AbstractSplitterCommon.get_out_going_vertices) - def get_out_going_vertices(self, partition_id): + def get_out_going_vertices(self, partition_id) -> List[SDRAMMachineVertex]: return self._post_vertices @overrides(AbstractSplitterCommon.get_in_coming_vertices) - def get_in_coming_vertices(self, partition_id): + def get_in_coming_vertices(self, partition_id) -> SDRAMMachineVertex: return [self._pre_vertex] def create_machine_vertices(self, chip_counter): # slices - self._pre_slice = Slice( + pre_slice = Slice( 0, int(self.governed_app_vertex.n_atoms / self.N_VERTS)) + post_slices = list() for count in range(1, self.N_VERTS): - self._post_slices.append(Slice( - self._pre_slice.n_atoms * count, - self._pre_slice.n_atoms * count + self._pre_slice.n_atoms)) + post_slices.append(Slice( + pre_slice.n_atoms * count, + pre_slice.n_atoms * count + pre_slice.n_atoms)) # mac verts - self._pre_vertex = SDRAMMachineVertex( - vertex_slice=self._pre_slice, label=None, + self.__pre_vertex = SDRAMMachineVertex( + vertex_slice=pre_slice, label=None, app_vertex=self.governed_app_vertex, sdram_cost=20) self.governed_app_vertex.remember_machine_vertex(self._pre_vertex) - for vertex_slice in self._post_slices: + for vertex_slice in post_slices: post_vertex = SDRAMMachineVertex( vertex_slice=vertex_slice, label=None, app_vertex=self.governed_app_vertex) @@ -84,20 +92,25 @@ def create_machine_vertices(self, chip_counter): return 1 @overrides(AbstractSplitterCommon.get_out_going_slices) - def get_out_going_slices(self): + def get_out_going_slices(self) -> List[Slice]: return [v.vertex_slice for v in self._post_vertices] @overrides(AbstractSplitterCommon.get_in_coming_slices) - def get_in_coming_slices(self): + def get_in_coming_slices(self) -> List[Slice]: return [self._pre_vertex.vertex_slice] @overrides(AbstractSplitterCommon.machine_vertices_for_recording) - def machine_vertices_for_recording(self, variable_to_record): + def machine_vertices_for_recording( + self, variable_to_record) -> List[SDRAMMachineVertex]: return [self._pre_vertex].extend(self._post_vertices) @overrides(AbstractSplitterCommon.reset_called) - def reset_called(self): + def reset_called(self) -> None: pass - def get_internal_sdram_partitions(self): + @overrides(AbstractSplitterCommon.get_internal_sdram_partitions) + def get_internal_sdram_partitions( + self) -> List[DestinationSegmentedSDRAMMachinePartition]: + assert isinstance( + self._partition, DestinationSegmentedSDRAMMachinePartition) return [self._partition] diff --git a/gfe_integration_tests/sdram_edge_tests/test_multi_src_internal/sdram_splitter.py b/gfe_integration_tests/sdram_edge_tests/test_multi_src_internal/sdram_splitter.py index 8bbffb2b..fb0313b5 100644 --- a/gfe_integration_tests/sdram_edge_tests/test_multi_src_internal/sdram_splitter.py +++ b/gfe_integration_tests/sdram_edge_tests/test_multi_src_internal/sdram_splitter.py @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from typing import List from spinn_utilities.overrides import overrides from pacman.model.graphs.common import Slice from pacman.model.graphs.machine import SDRAMMachineEdge @@ -27,43 +28,47 @@ class SDRAMSplitter(AbstractSplitterCommon): __slots__ = [ "_pre_vertices", - "_pre_slices", - "_post_slice", - "_post_vertex", + "__post_vertex", "_partition"] def __init__(self): super().__init__() - self._pre_vertices = list() - self._post_vertex = None - self._pre_slices = list() - self._post_slice = None + self._pre_vertices: List[SourceSegmentedSDRAMMachinePartition] = list() + self.__post_vertex = None + + @property + def _post_vertex(self): + assert isinstance(self.__post_vertex, SDRAMMachineVertex) + return self.__post_vertex @overrides(AbstractSplitterCommon.get_out_going_vertices) - def get_out_going_vertices(self, partition_id): + def get_out_going_vertices( + self, partition_id) -> SourceSegmentedSDRAMMachinePartition: return [self._post_vertex] @overrides(AbstractSplitterCommon.get_in_coming_vertices) - def get_in_coming_vertices(self, partition_id): + def get_in_coming_vertices( + self, partition_id) -> List[SourceSegmentedSDRAMMachinePartition]: return self._pre_vertices def create_machine_vertices(self, chip_counter): # slices - self._post_slice = Slice( + post_slice = Slice( 0, int(self.governed_app_vertex.n_atoms / self.N_VERTS)) + pre_slices = list() for count in range(1, self.N_VERTS): - self._pre_slices.append(Slice( - self._post_slice.n_atoms * count, - self._post_slice.n_atoms * count + self._post_slice.n_atoms)) + pre_slices.append(Slice( + post_slice.n_atoms * count, + post_slice.n_atoms * count + post_slice.n_atoms)) # mac verts - self._post_vertex = SDRAMMachineVertex( - vertex_slice=self._post_slice, label=None, + self.__post_vertex = SDRAMMachineVertex( + vertex_slice=post_slice, label=None, app_vertex=self.governed_app_vertex) self.governed_app_vertex.remember_machine_vertex(self._post_vertex) - for vertex_slice in self._pre_slices: + for vertex_slice in pre_slices: pre_vertex = SDRAMMachineVertex( vertex_slice=vertex_slice, label=None, app_vertex=self.governed_app_vertex, sdram_cost=20) @@ -82,21 +87,25 @@ def create_machine_vertices(self, chip_counter): chip_counter.add_core(pre_vertex.sdram_required) @overrides(AbstractSplitterCommon.get_out_going_slices) - def get_out_going_slices(self): + def get_out_going_slices(self) -> Slice: return [self._post_vertex.vertex_slice] @overrides(AbstractSplitterCommon.get_in_coming_slices) - def get_in_coming_slices(self): + def get_in_coming_slices(self) -> List[Slice]: return [v.vertex_slice for v in self._pre_vertices] @overrides(AbstractSplitterCommon.machine_vertices_for_recording) - def machine_vertices_for_recording(self, variable_to_record): + def machine_vertices_for_recording( + self, variable_to_record) -> List[SourceSegmentedSDRAMMachinePartition]: return [self._post_vertex].extend(self._pre_vertices) @overrides(AbstractSplitterCommon.reset_called) - def reset_called(self): + def reset_called(self) -> None: pass @overrides(AbstractSplitterCommon.get_internal_sdram_partitions) - def get_internal_sdram_partitions(self): + def get_internal_sdram_partitions( + self) -> SourceSegmentedSDRAMMachinePartition: + assert isinstance( + self._partition, SourceSegmentedSDRAMMachinePartition) return [self._partition] diff --git a/gfe_integration_tests/test_extra_monitor/sdram_writer.py b/gfe_integration_tests/test_extra_monitor/sdram_writer.py index 9a01fbb9..43f10a67 100644 --- a/gfe_integration_tests/test_extra_monitor/sdram_writer.py +++ b/gfe_integration_tests/test_extra_monitor/sdram_writer.py @@ -13,14 +13,18 @@ # limitations under the License. from enum import IntEnum +from typing import Iterable, Optional from spinn_utilities.overrides import overrides +from spinn_machine.tags import IPTag, ReverseIPTag from spinnman.model.enums import ExecutableType from pacman.model.graphs.machine import MachineVertex +from pacman.model.placements import Placement from pacman.model.resources import ConstantSDRAM from spinn_front_end_common.abstract_models import ( AbstractHasAssociatedBinary) from spinn_front_end_common.abstract_models.impl import ( MachineDataSpecableVertex) +from spinn_front_end_common.interface.ds import DataSpecificationGenerator from spinn_front_end_common.interface.simulation import simulation_utilities from spinn_front_end_common.utilities.constants import ( SIMULATION_N_BYTES, SYSTEM_BYTES_REQUIREMENT, BYTES_PER_KB) @@ -55,7 +59,9 @@ def get_binary_start_type(self): @overrides(MachineDataSpecableVertex.generate_machine_data_specification) def generate_machine_data_specification( - self, spec, placement, iptags, reverse_iptags): + self, spec: DataSpecificationGenerator, placement: Placement, + iptags: Optional[Iterable[IPTag]], + reverse_iptags: Optional[Iterable[ReverseIPTag]]): # Reserve SDRAM space for memory areas: self._reserve_memory_regions(spec) diff --git a/gfe_integration_tests/test_profile/profiled_vertex.py b/gfe_integration_tests/test_profile/profiled_vertex.py index a71e4f64..abf4668e 100644 --- a/gfe_integration_tests/test_profile/profiled_vertex.py +++ b/gfe_integration_tests/test_profile/profiled_vertex.py @@ -13,15 +13,20 @@ # limitations under the License. from enum import IntEnum +from typing import Iterable, Optional import logging from spinn_utilities.log import FormatAdapter from spinn_utilities.overrides import overrides +from spinn_machine.tags import IPTag, ReverseIPTag from pacman.model.graphs.machine import MachineVertex +from pacman.model.placements import Placement from pacman.model.resources import ConstantSDRAM from spinn_front_end_common.utilities.constants import SYSTEM_BYTES_REQUIREMENT from spinn_front_end_common.abstract_models.impl import ( MachineDataSpecableVertex) -from spinn_front_end_common.interface.profiling import AbstractHasProfileData +from spinn_front_end_common.interface.ds import DataSpecificationGenerator +from spinn_front_end_common.interface.profiling import ( + AbstractHasProfileData, ProfileData) from spinn_front_end_common.interface.profiling.profile_utils import ( get_profile_region_size, reserve_profile_region, write_profile_region_data, get_profiling_data) @@ -52,14 +57,16 @@ def __init__(self, label=None): @property @overrides(MachineVertex.sdram_required) - def sdram_required(self): + def sdram_required(self) -> ConstantSDRAM: return ConstantSDRAM( SYSTEM_BYTES_REQUIREMENT + get_profile_region_size(N_SAMPLES)) @overrides(MachineDataSpecableVertex.generate_machine_data_specification) def generate_machine_data_specification( - self, spec, placement, iptags, reverse_iptags): + self, spec: DataSpecificationGenerator, placement: Placement, + iptags: Optional[Iterable[IPTag]], + reverse_iptags: Optional[Iterable[ReverseIPTag]]): # Generate the system data region for simulation .c requirements self.generate_system_region(spec) @@ -71,6 +78,6 @@ def generate_machine_data_specification( spec.end_specification() @overrides(AbstractHasProfileData.get_profile_data) - def get_profile_data(self, placement): + def get_profile_data(self, placement: Placement) -> ProfileData: return get_profiling_data( DataRegions.PROFILE.value, PROFILE_TAGS, placement) diff --git a/spinnaker_graph_front_end/utilities/simulator_vertex.py b/spinnaker_graph_front_end/utilities/simulator_vertex.py index 1454a4e6..1cc510e7 100644 --- a/spinnaker_graph_front_end/utilities/simulator_vertex.py +++ b/spinnaker_graph_front_end/utilities/simulator_vertex.py @@ -36,7 +36,7 @@ class SimulatorVertex(MachineVertex, AbstractHasAssociatedBinary): __slots__ = ["_binary_name", "__front_end"] - def __init__(self, label, binary_name, vertex_slice=None): + def __init__(self, label, binary_name: str, vertex_slice=None): """ :param str label: The label for the vertex. @@ -56,11 +56,11 @@ def __init__(self, label, binary_name, vertex_slice=None): self.__front_end = sys.modules["spinnaker_graph_front_end"] @overrides(AbstractHasAssociatedBinary.get_binary_file_name) - def get_binary_file_name(self): + def get_binary_file_name(self) -> str: return self._binary_name @overrides(AbstractHasAssociatedBinary.get_binary_start_type) - def get_binary_start_type(self): + def get_binary_start_type(self) -> ExecutableType: return ExecutableType.USES_SIMULATION_INTERFACE @property From 8c8c148142e6150daddf0ca5e5903ebaf4f77faf Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 21 Dec 2023 16:38:02 +0000 Subject: [PATCH 03/16] overrides typing --- gfe_examples/hello_world/hello_world_vertex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfe_examples/hello_world/hello_world_vertex.py b/gfe_examples/hello_world/hello_world_vertex.py index 1e977926..58f93e78 100644 --- a/gfe_examples/hello_world/hello_world_vertex.py +++ b/gfe_examples/hello_world/hello_world_vertex.py @@ -94,6 +94,6 @@ def get_recorded_region_ids(self) -> List[int]: return [Channels.HELLO] @overrides(AbstractReceiveBuffersToHost.get_recording_region_base_address) - def get_recording_region_base_address(self, placement) -> int: + def get_recording_region_base_address(self, placement: Placement) -> int: return locate_memory_region_for_placement( placement, DataRegions.STRING_DATA) From fb5c930e77fa50003760f6d74e7c8059ec41047a Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 8 Jan 2024 08:24:58 +0000 Subject: [PATCH 04/16] activate mypy --- .github/workflows/python_actions.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index cc519a03..d40b60dc 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -75,6 +75,9 @@ jobs: package: ${{ env.BASE_PKG }} gfe_examples language: en_GB + - name: Lint with mypy + run: mypy $BASE_PKG + validate: runs-on: ubuntu-latest strategy: From dbc2c27fad410f64be45e2e996b5e8d3d32bd225 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 8 Jan 2024 09:33:59 +0000 Subject: [PATCH 05/16] Install mypy --- .github/workflows/python_actions.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index d40b60dc..64d08b1a 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -42,6 +42,9 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install pip, etc uses: ./support/actions/python-tools + - name: Install mypy + run: pip install mypy + - name: Install Spinnaker Dependencies uses: ./support/actions/install-spinn-deps with: From 8a922391979cbe999f4e80bde8b76cd22c971a37 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 8 Jan 2024 09:52:00 +0000 Subject: [PATCH 06/16] yml spacing --- .github/workflows/python_actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index 64d08b1a..0ef3758d 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -43,7 +43,7 @@ jobs: - name: Install pip, etc uses: ./support/actions/python-tools - name: Install mypy - run: pip install mypy + run: pip install mypy - name: Install Spinnaker Dependencies uses: ./support/actions/install-spinn-deps From 85209e889c34b3c2ffb9d6a9436c3ac2b84af055 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 8 Jan 2024 10:11:08 +0000 Subject: [PATCH 07/16] typing --- spinnaker_graph_front_end/utilities/data_utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spinnaker_graph_front_end/utilities/data_utils.py b/spinnaker_graph_front_end/utilities/data_utils.py index c064e514..b18c27bc 100644 --- a/spinnaker_graph_front_end/utilities/data_utils.py +++ b/spinnaker_graph_front_end/utilities/data_utils.py @@ -12,12 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +from pacman.model.graphs.machine import MachineVertex from spinn_front_end_common.utilities.constants import SIMULATION_N_BYTES +from spinn_front_end_common.interface.ds import DataSpecificationGenerator from spinn_front_end_common.interface.simulation.simulation_utilities import ( get_simulation_header_array, get_simulation_header_array_no_timestep) -def generate_system_data_region(spec, region_id, machine_vertex): +def generate_system_data_region(spec: DataSpecificationGenerator, + region_id: int, machine_vertex: MachineVertex): """ Generate a system data region for time-based simulations. @@ -38,7 +41,9 @@ def generate_system_data_region(spec, region_id, machine_vertex): machine_vertex.get_binary_file_name())) -def generate_steps_system_data_region(spec, region_id, machine_vertex): +def generate_steps_system_data_region( + spec: DataSpecificationGenerator, region_id: int, + machine_vertex: MachineVertex): """ Generate a system data region for step-based simulations. From 29f913082e7ee1b19ecac9112eab396af7859a89 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 8 Jan 2024 10:17:07 +0000 Subject: [PATCH 08/16] import MachineDataSpecableVertex --- spinnaker_graph_front_end/utilities/data_utils.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spinnaker_graph_front_end/utilities/data_utils.py b/spinnaker_graph_front_end/utilities/data_utils.py index b18c27bc..857751ec 100644 --- a/spinnaker_graph_front_end/utilities/data_utils.py +++ b/spinnaker_graph_front_end/utilities/data_utils.py @@ -12,15 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -from pacman.model.graphs.machine import MachineVertex +from spinn_front_end_common.abstract_models.impl import ( + MachineDataSpecableVertex) from spinn_front_end_common.utilities.constants import SIMULATION_N_BYTES from spinn_front_end_common.interface.ds import DataSpecificationGenerator from spinn_front_end_common.interface.simulation.simulation_utilities import ( get_simulation_header_array, get_simulation_header_array_no_timestep) -def generate_system_data_region(spec: DataSpecificationGenerator, - region_id: int, machine_vertex: MachineVertex): +def generate_system_data_region( + spec: DataSpecificationGenerator, region_id: int, + machine_vertex: MachineDataSpecableVertex): """ Generate a system data region for time-based simulations. @@ -43,7 +45,7 @@ def generate_system_data_region(spec: DataSpecificationGenerator, def generate_steps_system_data_region( spec: DataSpecificationGenerator, region_id: int, - machine_vertex: MachineVertex): + machine_vertex: MachineDataSpecableVertex): """ Generate a system data region for step-based simulations. From a370be20b59675a54ff46653e7f54cc26dc43830 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 8 Jan 2024 10:22:05 +0000 Subject: [PATCH 09/16] correct typing --- spinnaker_graph_front_end/utilities/data_utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spinnaker_graph_front_end/utilities/data_utils.py b/spinnaker_graph_front_end/utilities/data_utils.py index 857751ec..0dd37a0e 100644 --- a/spinnaker_graph_front_end/utilities/data_utils.py +++ b/spinnaker_graph_front_end/utilities/data_utils.py @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from spinn_front_end_common.abstract_models.impl import ( - MachineDataSpecableVertex) from spinn_front_end_common.utilities.constants import SIMULATION_N_BYTES from spinn_front_end_common.interface.ds import DataSpecificationGenerator from spinn_front_end_common.interface.simulation.simulation_utilities import ( get_simulation_header_array, get_simulation_header_array_no_timestep) +from .simulator_vertex import SimulatorVertex def generate_system_data_region( spec: DataSpecificationGenerator, region_id: int, - machine_vertex: MachineDataSpecableVertex): + machine_vertex: SimulatorVertex): """ Generate a system data region for time-based simulations. @@ -45,7 +44,7 @@ def generate_system_data_region( def generate_steps_system_data_region( spec: DataSpecificationGenerator, region_id: int, - machine_vertex: MachineDataSpecableVertex): + machine_vertex: SimulatorVertex): """ Generate a system data region for step-based simulations. From 93028ca69320241323e6c8ff1fc0b7badb6c3b0e Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 8 Jan 2024 10:26:46 +0000 Subject: [PATCH 10/16] if TYPE_CHECKING: import guard --- spinnaker_graph_front_end/utilities/data_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spinnaker_graph_front_end/utilities/data_utils.py b/spinnaker_graph_front_end/utilities/data_utils.py index 0dd37a0e..83943d89 100644 --- a/spinnaker_graph_front_end/utilities/data_utils.py +++ b/spinnaker_graph_front_end/utilities/data_utils.py @@ -12,11 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +from typing import TYPE_CHECKING from spinn_front_end_common.utilities.constants import SIMULATION_N_BYTES from spinn_front_end_common.interface.ds import DataSpecificationGenerator from spinn_front_end_common.interface.simulation.simulation_utilities import ( get_simulation_header_array, get_simulation_header_array_no_timestep) -from .simulator_vertex import SimulatorVertex +if TYPE_CHECKING: + from .simulator_vertex import SimulatorVertex def generate_system_data_region( From edd4df44ec7114dee3e54bac16e05db14c0d06f6 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 8 Jan 2024 10:35:55 +0000 Subject: [PATCH 11/16] py.typed marker --- spinnaker_graph_front_end/py.typed | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 spinnaker_graph_front_end/py.typed diff --git a/spinnaker_graph_front_end/py.typed b/spinnaker_graph_front_end/py.typed new file mode 100644 index 00000000..91eaa0c5 --- /dev/null +++ b/spinnaker_graph_front_end/py.typed @@ -0,0 +1,13 @@ +# Copyright (c) 2023 The University of Manchester +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. From 2e69c5f8c9622c30e4f96fde5182f3882406051e Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 8 Jan 2024 10:49:23 +0000 Subject: [PATCH 12/16] quote type --- spinnaker_graph_front_end/utilities/data_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spinnaker_graph_front_end/utilities/data_utils.py b/spinnaker_graph_front_end/utilities/data_utils.py index 83943d89..e6b73f30 100644 --- a/spinnaker_graph_front_end/utilities/data_utils.py +++ b/spinnaker_graph_front_end/utilities/data_utils.py @@ -23,7 +23,7 @@ def generate_system_data_region( spec: DataSpecificationGenerator, region_id: int, - machine_vertex: SimulatorVertex): + machine_vertex: 'SimulatorVertex'): """ Generate a system data region for time-based simulations. @@ -46,7 +46,7 @@ def generate_system_data_region( def generate_steps_system_data_region( spec: DataSpecificationGenerator, region_id: int, - machine_vertex: SimulatorVertex): + machine_vertex: 'SimulatorVertex'): """ Generate a system data region for step-based simulations. From a6321266f57273361f67d5afc123dcb6464f708f Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 9 Jan 2024 09:32:42 +0000 Subject: [PATCH 13/16] typing --- .../partitioned_example_b_no_vis_buffer/conways_basic_cell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfe_examples/Conways/partitioned_example_b_no_vis_buffer/conways_basic_cell.py b/gfe_examples/Conways/partitioned_example_b_no_vis_buffer/conways_basic_cell.py index 98c0aa71..c9cb1a07 100644 --- a/gfe_examples/Conways/partitioned_example_b_no_vis_buffer/conways_basic_cell.py +++ b/gfe_examples/Conways/partitioned_example_b_no_vis_buffer/conways_basic_cell.py @@ -176,6 +176,6 @@ def get_recorded_region_ids(self) -> List[int]: return [Channels.STATE_LOG] @overrides(AbstractReceiveBuffersToHost.get_recording_region_base_address) - def get_recording_region_base_address(self, placement) -> int: + def get_recording_region_base_address(self, placement: Placement) -> int: return locate_memory_region_for_placement( placement, DataRegions.RESULTS) From 95ea0e15c9fc6d5ce4c001633dab5677929b1252 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 11 Jan 2024 08:08:14 +0000 Subject: [PATCH 14/16] more typing --- .../test_constant_internal/sdram_splitter_internal.py | 4 ++-- .../test_multi_dest_internal/sdram_splitter.py | 4 ++-- .../test_multi_src_internal/sdram_splitter.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gfe_integration_tests/sdram_edge_tests/test_constant_internal/sdram_splitter_internal.py b/gfe_integration_tests/sdram_edge_tests/test_constant_internal/sdram_splitter_internal.py index 94efa3c9..4fac689a 100644 --- a/gfe_integration_tests/sdram_edge_tests/test_constant_internal/sdram_splitter_internal.py +++ b/gfe_integration_tests/sdram_edge_tests/test_constant_internal/sdram_splitter_internal.py @@ -47,11 +47,11 @@ def _post_vertex(self): return self.__post_vertex @overrides(AbstractSplitterCommon.get_out_going_vertices) - def get_out_going_vertices(self, partition_id) -> List[SDRAMMachineVertex]: + def get_out_going_vertices(self, partition_id: str) -> List[SDRAMMachineVertex]: return [self._pre_vertex] @overrides(AbstractSplitterCommon.get_in_coming_vertices) - def get_in_coming_vertices(self, partition_id) -> list[SDRAMMachineVertex]: + def get_in_coming_vertices(self, partition_id: str) -> list[SDRAMMachineVertex]: return [self._post_vertex] def create_machine_vertices(self, chip_counter): diff --git a/gfe_integration_tests/sdram_edge_tests/test_multi_dest_internal/sdram_splitter.py b/gfe_integration_tests/sdram_edge_tests/test_multi_dest_internal/sdram_splitter.py index 5ad9d3b0..61180fb3 100644 --- a/gfe_integration_tests/sdram_edge_tests/test_multi_dest_internal/sdram_splitter.py +++ b/gfe_integration_tests/sdram_edge_tests/test_multi_dest_internal/sdram_splitter.py @@ -47,11 +47,11 @@ def __post_vertex(self): return self.__post_vertex @overrides(AbstractSplitterCommon.get_out_going_vertices) - def get_out_going_vertices(self, partition_id) -> List[SDRAMMachineVertex]: + def get_out_going_vertices(self, partition_id: str) -> List[SDRAMMachineVertex]: return self._post_vertices @overrides(AbstractSplitterCommon.get_in_coming_vertices) - def get_in_coming_vertices(self, partition_id) -> SDRAMMachineVertex: + def get_in_coming_vertices(self, partition_id: str) -> SDRAMMachineVertex: return [self._pre_vertex] def create_machine_vertices(self, chip_counter): diff --git a/gfe_integration_tests/sdram_edge_tests/test_multi_src_internal/sdram_splitter.py b/gfe_integration_tests/sdram_edge_tests/test_multi_src_internal/sdram_splitter.py index fb0313b5..ebf92f0e 100644 --- a/gfe_integration_tests/sdram_edge_tests/test_multi_src_internal/sdram_splitter.py +++ b/gfe_integration_tests/sdram_edge_tests/test_multi_src_internal/sdram_splitter.py @@ -43,12 +43,12 @@ def _post_vertex(self): @overrides(AbstractSplitterCommon.get_out_going_vertices) def get_out_going_vertices( - self, partition_id) -> SourceSegmentedSDRAMMachinePartition: + self, partition_id: str) -> SourceSegmentedSDRAMMachinePartition: return [self._post_vertex] @overrides(AbstractSplitterCommon.get_in_coming_vertices) def get_in_coming_vertices( - self, partition_id) -> List[SourceSegmentedSDRAMMachinePartition]: + self, partition_id: str) -> List[SourceSegmentedSDRAMMachinePartition]: return self._pre_vertices def create_machine_vertices(self, chip_counter): From 1d2473c1707560acd2343cf76fc2f058846bad49 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 15 Jan 2024 06:36:38 +0000 Subject: [PATCH 15/16] typing --- .../sdram_edge_tests/test_multi_dest_internal/sdram_splitter.py | 2 +- .../sdram_edge_tests/test_multi_src_internal/sdram_splitter.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gfe_integration_tests/sdram_edge_tests/test_multi_dest_internal/sdram_splitter.py b/gfe_integration_tests/sdram_edge_tests/test_multi_dest_internal/sdram_splitter.py index 61180fb3..a866a3d8 100644 --- a/gfe_integration_tests/sdram_edge_tests/test_multi_dest_internal/sdram_splitter.py +++ b/gfe_integration_tests/sdram_edge_tests/test_multi_dest_internal/sdram_splitter.py @@ -101,7 +101,7 @@ def get_in_coming_slices(self) -> List[Slice]: @overrides(AbstractSplitterCommon.machine_vertices_for_recording) def machine_vertices_for_recording( - self, variable_to_record) -> List[SDRAMMachineVertex]: + self, variable_to_record: str) -> List[SDRAMMachineVertex]: return [self._pre_vertex].extend(self._post_vertices) @overrides(AbstractSplitterCommon.reset_called) diff --git a/gfe_integration_tests/sdram_edge_tests/test_multi_src_internal/sdram_splitter.py b/gfe_integration_tests/sdram_edge_tests/test_multi_src_internal/sdram_splitter.py index ebf92f0e..85947749 100644 --- a/gfe_integration_tests/sdram_edge_tests/test_multi_src_internal/sdram_splitter.py +++ b/gfe_integration_tests/sdram_edge_tests/test_multi_src_internal/sdram_splitter.py @@ -96,7 +96,7 @@ def get_in_coming_slices(self) -> List[Slice]: @overrides(AbstractSplitterCommon.machine_vertices_for_recording) def machine_vertices_for_recording( - self, variable_to_record) -> List[SourceSegmentedSDRAMMachinePartition]: + self, variable_to_record: str) -> List[SourceSegmentedSDRAMMachinePartition]: return [self._post_vertex].extend(self._pre_vertices) @overrides(AbstractSplitterCommon.reset_called) From 3080b84dad87c63644a852bb4316e3e35a280780 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 15 Jan 2024 14:51:07 +0000 Subject: [PATCH 16/16] pylint disables --- gfe_examples/live_io/live_io.py | 2 +- spinnaker_graph_front_end/__init__.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gfe_examples/live_io/live_io.py b/gfe_examples/live_io/live_io.py index 6bdbc411..1ec45f39 100644 --- a/gfe_examples/live_io/live_io.py +++ b/gfe_examples/live_io/live_io.py @@ -48,7 +48,7 @@ def start_sending(label, c): def end_sim(label, c): - # pylint: disable=unused-argument + # pylint: disable=unused-argument,global-statement global running running = False diff --git a/spinnaker_graph_front_end/__init__.py b/spinnaker_graph_front_end/__init__.py index eb3362bf..9542e3ca 100644 --- a/spinnaker_graph_front_end/__init__.py +++ b/spinnaker_graph_front_end/__init__.py @@ -113,6 +113,7 @@ def setup(model_binary_module=None, :raise ~spinn_front_end_common.utilities.exceptions.ConfigurationException: if mutually exclusive options are given. """ + # pylint: disable=global-statement global __simulator # pylint: disable=redefined-outer-name logger.info( @@ -223,6 +224,7 @@ def add_machine_vertex_instance(machine_vertex): app_vertex = AbstractOneAppOneMachineVertex( machine_vertex, machine_vertex.label) FecDataView.add_vertex(app_vertex) + # pylint: disable=protected-access machine_vertex._app_vertex = app_vertex