From 194b1eca614e53e11e28029685e1fc90c72fea9d Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 4 Dec 2023 16:07:03 +0000 Subject: [PATCH 01/59] typing overrides --- spinnman/spalloc/spalloc_client.py | 25 +++++++++++++------- spinnman/spalloc/spalloc_eieio_connection.py | 2 +- spinnman/spalloc/spalloc_eieio_listener.py | 2 +- spinnman/spalloc/spalloc_job.py | 4 ++-- spinnman/spalloc/spalloc_scp_connection.py | 7 +++--- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/spinnman/spalloc/spalloc_client.py b/spinnman/spalloc/spalloc_client.py index 462cb0963..50768f206 100644 --- a/spinnman/spalloc/spalloc_client.py +++ b/spinnman/spalloc/spalloc_client.py @@ -212,8 +212,11 @@ def create_job_rect( @overrides(AbstractSpallocClient.create_job_board) def create_job_board( - self, triad=None, physical=None, ip_address=None, - machine_name=None, keepalive=45) -> SpallocJob: + self, triad: Optional[Tuple[int, int, int]] = None, + physical: Optional[Tuple[int, int, int]] = None, + ip_address: Optional[str] = None, + machine_name: Optional[str] = None, + keepalive: int = 45) -> SpallocJob: board: JsonObject if triad: x, y, z = triad @@ -233,8 +236,12 @@ def create_job_board( @overrides(AbstractSpallocClient.create_job_rect_at_board) def create_job_rect_at_board( - self, width, height, triad=None, physical=None, ip_address=None, - machine_name=None, keepalive=45, max_dead_boards=0): + self, width: int, height: int, + triad: Optional[Tuple[int, int, int]] = None, + physical: Optional[Tuple[int, int, int]] = None, + ip_address: Optional[str] = None, + machine_name: Optional[str] = None, keepalive: int = 45, + max_dead_boards: int = 0) -> SpallocJob: if triad: x, y, z = triad board = {"x": int(x), "y": int(y), "z": int(z)} @@ -510,7 +517,7 @@ def __init__(self, session: Session, job_handle: str): self.__proxy_ping: Optional[_ProxyPing] = None @overrides(SpallocJob.get_session_credentials_for_db) - def get_session_credentials_for_db(self): + def get_session_credentials_for_db(self) -> Mapping[Tuple[str, str], str]: config = {} config["SPALLOC", "service uri"] = self._service_url config["SPALLOC", "job uri"] = self._url @@ -634,7 +641,7 @@ def wait_until_ready(self, timeout: Optional[int] = None, raise SpallocException("job was unexpectedly destroyed") @overrides(SpallocJob.destroy) - def destroy(self, reason: str = "finished") -> None: + def destroy(self, reason: str = "finished"): if self.__keepalive_handle: self.__keepalive_handle.close() self.__keepalive_handle = None @@ -871,7 +878,7 @@ def __init__( super().__init__(ws, receiver) @overrides(_ProxiedConnection._open_connection) - def _open_connection(self): + def _open_connection(self) -> int: handle, = self._call( ProxyProtocol.OPEN, _open_req, _open_close_res, *self.__connect_args) @@ -882,7 +889,7 @@ def is_connected(self) -> bool: return self._connected @overrides(Connection.close) - def close(self): + def close(self) -> None: self._close() @overrides(SpallocProxiedConnection.send) @@ -941,7 +948,7 @@ def close(self) -> None: self._close() @overrides(SpallocProxiedConnection.send) - def send(self, data: bytes) -> None: + def send(self, data: bytes): self._throw_if_closed() raise IOError("socket is not open for sending") diff --git a/spinnman/spalloc/spalloc_eieio_connection.py b/spinnman/spalloc/spalloc_eieio_connection.py index 613c7c7db..1a8c1c6b9 100644 --- a/spinnman/spalloc/spalloc_eieio_connection.py +++ b/spinnman/spalloc/spalloc_eieio_connection.py @@ -45,7 +45,7 @@ class SpallocEIEIOConnection( __slots__ = () @overrides(EIEIOConnection.send_eieio_message) - def send_eieio_message(self, eieio_message): + def send_eieio_message(self, eieio_message: AbstractEIEIOMessage): # Not normally used, as packets need headers to go to SpiNNaker self.send(eieio_message.bytestring) diff --git a/spinnman/spalloc/spalloc_eieio_listener.py b/spinnman/spalloc/spalloc_eieio_listener.py index 435fba604..9e7e2b94a 100644 --- a/spinnman/spalloc/spalloc_eieio_listener.py +++ b/spinnman/spalloc/spalloc_eieio_listener.py @@ -57,7 +57,7 @@ def receive_eieio_message( return read_eieio_data_message(data, 0) @overrides(SpallocProxiedConnection.send) - def send(self, data): + def send(self, data: bytes): """ .. note:: This class does not allow sending. diff --git a/spinnman/spalloc/spalloc_job.py b/spinnman/spalloc/spalloc_job.py index 7cc8caac4..adb7b2b31 100644 --- a/spinnman/spalloc/spalloc_job.py +++ b/spinnman/spalloc/spalloc_job.py @@ -34,7 +34,7 @@ class SpallocJob(object, metaclass=AbstractBase): __slots__ = () @abstractmethod - def get_state(self, wait_for_change=False) -> SpallocState: + def get_state(self, wait_for_change: bool = False) -> SpallocState: """ Get the current state of the machine. @@ -183,7 +183,7 @@ def destroy(self, reason: str = "finished"): raise NotImplementedError() @abstractmethod - def keepalive(self): + def keepalive(self) -> None: """ Signal the job that we want it to stay alive for a while longer. """ diff --git a/spinnman/spalloc/spalloc_scp_connection.py b/spinnman/spalloc/spalloc_scp_connection.py index a88c140fc..bfd42d377 100644 --- a/spinnman/spalloc/spalloc_scp_connection.py +++ b/spinnman/spalloc/spalloc_scp_connection.py @@ -55,8 +55,8 @@ def send_sdp_message(self, sdp_message: SDPMessage): self.send(_TWO_SKIP + sdp_message.bytestring) @overrides(SCAMPConnection.receive_scp_response) - def receive_scp_response( - self, timeout=1.0) -> Tuple[SCPResult, int, bytes, int]: + def receive_scp_response(self, timeout: Optional[float] = 1.0) -> Tuple[ + SCPResult, int, bytes, int]: data = self.receive(timeout) result, sequence = _TWO_SHORTS.unpack_from(data, 10) return SCPResult(result), sequence, data, 2 @@ -67,7 +67,8 @@ def send_scp_request(self, scp_request: AbstractSCPRequest): @overrides(SCAMPConnection.get_scp_data) def get_scp_data( - self, scp_request: AbstractSCPRequest, x=None, y=None) -> bytes: + self, scp_request: AbstractSCPRequest, + x: Optional[int] = None, y: Optional[int] = None) -> bytes: if x is None: x = self.chip_x if y is None: From fc3e7269a95feadfa6fe2c2fe1d8419150927d59 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 8 Dec 2023 11:51:22 +0000 Subject: [PATCH 02/59] more typing of overide methods --- .../connections/udp_packet_connections/bmp_connection.py | 4 ++-- .../eieio/command_messages/eieio_command_message.py | 7 ++++--- spinnman/messages/scp/impl/check_ok_response.py | 2 +- spinnman/messages/scp/impl/sdram_alloc.py | 2 +- spinnman/processes/get_exclude_cpu_info_process.py | 2 +- spinnman/processes/get_include_cpu_info_process.py | 2 +- spinnman/transceiver/base_transceiver.py | 6 +++--- spinnman/transceiver/mockable_transceiver.py | 9 +++++---- spinnman/transceiver/transceiver.py | 7 ++++--- 9 files changed, 22 insertions(+), 19 deletions(-) diff --git a/spinnman/connections/udp_packet_connections/bmp_connection.py b/spinnman/connections/udp_packet_connections/bmp_connection.py index 63e45379e..584c4129c 100644 --- a/spinnman/connections/udp_packet_connections/bmp_connection.py +++ b/spinnman/connections/udp_packet_connections/bmp_connection.py @@ -13,7 +13,7 @@ # limitations under the License. import struct -from typing import Sequence, Tuple +from typing import Optional, Sequence, Tuple from spinn_utilities.overrides import overrides from .udp_connection import UDPConnection from spinnman.constants import SCP_SCAMP_PORT @@ -74,7 +74,7 @@ def get_scp_data(self, scp_request: AbstractSCPRequest) -> bytes: return _TWO_SKIP.pack() + scp_request.bytestring @overrides(AbstractSCPConnection.receive_scp_response) - def receive_scp_response(self, timeout=1.0) -> Tuple[ + def receive_scp_response(self, timeout: Optional[float] = 1.0) -> Tuple[ SCPResult, int, bytes, int]: data = self.receive(timeout) result, sequence = _TWO_SHORTS.unpack_from(data, 10) diff --git a/spinnman/messages/eieio/command_messages/eieio_command_message.py b/spinnman/messages/eieio/command_messages/eieio_command_message.py index 906af845c..accdfe400 100644 --- a/spinnman/messages/eieio/command_messages/eieio_command_message.py +++ b/spinnman/messages/eieio/command_messages/eieio_command_message.py @@ -13,6 +13,7 @@ # limitations under the License. from spinn_utilities.overrides import overrides from spinnman.messages.eieio import AbstractEIEIOMessage +from spinnman.messages.eieio.command_messages import EIEIOCommandHeader class EIEIOCommandMessage(AbstractEIEIOMessage): @@ -24,7 +25,7 @@ class EIEIOCommandMessage(AbstractEIEIOMessage): "_eieio_command_header", "_offset") - def __init__(self, eieio_command_header, data=None, offset=0): + def __init__(self, eieio_command_header: EIEIOCommandHeader, data=None, offset=0): """ :param EIEIOCommandHeader eieio_command_header: The header of the message @@ -40,7 +41,7 @@ def __init__(self, eieio_command_header, data=None, offset=0): @property @overrides(AbstractEIEIOMessage.eieio_header) - def eieio_header(self): + def eieio_header(self) -> EIEIOCommandHeader: """ :rtype: EIEIOCommandHeader """ @@ -60,7 +61,7 @@ def from_bytestring(command_header, data, offset): @property @overrides(AbstractEIEIOMessage.bytestring) - def bytestring(self): + def bytestring(self) -> bytes: return self._eieio_command_header.bytestring @staticmethod diff --git a/spinnman/messages/scp/impl/check_ok_response.py b/spinnman/messages/scp/impl/check_ok_response.py index 662ea9d9b..4f4a140b0 100644 --- a/spinnman/messages/scp/impl/check_ok_response.py +++ b/spinnman/messages/scp/impl/check_ok_response.py @@ -37,7 +37,7 @@ def __init__(self, operation: str, command): self._command = command @overrides(AbstractSCPResponse.read_data_bytestring) - def read_data_bytestring(self, data: bytes, offset: int) -> None: + def read_data_bytestring(self, data: bytes, offset: int): result = self.scp_response_header.result if result != SCPResult.RC_OK: raise SpinnmanUnexpectedResponseCodeException( diff --git a/spinnman/messages/scp/impl/sdram_alloc.py b/spinnman/messages/scp/impl/sdram_alloc.py index 30821d2f5..ad904146b 100644 --- a/spinnman/messages/scp/impl/sdram_alloc.py +++ b/spinnman/messages/scp/impl/sdram_alloc.py @@ -42,7 +42,7 @@ def __init__(self, size: int): self._base_address: Optional[int] = None @overrides(AbstractSCPResponse.read_data_bytestring) - def read_data_bytestring(self, data, offset): + def read_data_bytestring(self, data: bytes, offset: int): result = self.scp_response_header.result if result != SCPResult.RC_OK: raise SpinnmanUnexpectedResponseCodeException( diff --git a/spinnman/processes/get_exclude_cpu_info_process.py b/spinnman/processes/get_exclude_cpu_info_process.py index 7a5bbbbca..ca5bca04e 100644 --- a/spinnman/processes/get_exclude_cpu_info_process.py +++ b/spinnman/processes/get_exclude_cpu_info_process.py @@ -30,5 +30,5 @@ def __init__(self, connection_selector: ConnectionSelector, self.__states = states @overrides(GetCPUInfoProcess._is_desired) - def _is_desired(self, cpu_info: CPUInfo): + def _is_desired(self, cpu_info: CPUInfo) -> bool: return cpu_info.state not in self.__states diff --git a/spinnman/processes/get_include_cpu_info_process.py b/spinnman/processes/get_include_cpu_info_process.py index 2fd1154c4..749549983 100644 --- a/spinnman/processes/get_include_cpu_info_process.py +++ b/spinnman/processes/get_include_cpu_info_process.py @@ -35,5 +35,5 @@ def __init__(self, connection_selector: ConnectionSelector, self.__states = states @overrides(GetCPUInfoProcess._is_desired) - def _is_desired(self, cpu_info: CPUInfo): + def _is_desired(self, cpu_info: CPUInfo) -> bool: return cpu_info.state in self.__states diff --git a/spinnman/transceiver/base_transceiver.py b/spinnman/transceiver/base_transceiver.py index 65e4139e6..bf2a20acc 100644 --- a/spinnman/transceiver/base_transceiver.py +++ b/spinnman/transceiver/base_transceiver.py @@ -25,7 +25,7 @@ import time from typing import ( BinaryIO, Collection, Dict, FrozenSet, Iterable, Iterator, List, Optional, - Sequence, Tuple, TypeVar, Union, cast) + Sequence, Set, Tuple, TypeVar, Union, cast) from spinn_utilities.abstract_base import ( AbstractBase, abstractmethod) from spinn_utilities.config_holder import get_config_bool @@ -422,7 +422,7 @@ def add_scamp_connections(self, connections: Dict[XY, str]): self._scamp_connections) @overrides(Transceiver.get_connections) - def get_connections(self): + def get_connections(self) -> Set[Connection]: return self._all_connections def _get_machine_dimensions(self) -> MachineDimensions: @@ -1232,7 +1232,7 @@ def get_tags(self, connection: Optional[SCAMPConnection] = None @overrides(Transceiver.malloc_sdram) def malloc_sdram( - self, x: int, y: int, size: int, app_id: int, tag=0) -> int: + self, x: int, y: int, size: int, app_id: int, tag: int = 0) -> int: try: process = MallocSDRAMProcess(self._scamp_connection_selector) process.malloc_sdram(x, y, size, app_id, tag) diff --git a/spinnman/transceiver/mockable_transceiver.py b/spinnman/transceiver/mockable_transceiver.py index 558cc7505..126ee9732 100644 --- a/spinnman/transceiver/mockable_transceiver.py +++ b/spinnman/transceiver/mockable_transceiver.py @@ -16,7 +16,7 @@ from typing import ( BinaryIO, Collection, Dict, FrozenSet, Iterable, - List, Optional, Tuple, Union) + List, Optional, Set, Tuple, Union) from spinn_utilities.overrides import overrides from spinn_utilities.progress_bar import ProgressBar from spinn_utilities.typing.coords import XY @@ -24,6 +24,7 @@ CoreSubsets, FixedRouteEntry, Machine, MulticastRoutingEntry) from spinn_machine.tags import AbstractTag, IPTag, ReverseIPTag from spinnman.data import SpiNNManDataView +from spinnman.connections.abstract_classes import Connection from spinnman.connections.udp_packet_connections import BMPConnection from spinnman.connections.udp_packet_connections import ( SCAMPConnection, SDPConnection) @@ -69,7 +70,7 @@ def get_machine_details(self) -> Machine: return SpiNNManDataView.get_machine() @overrides(Transceiver.get_connections) - def get_connections(self): + def get_connections(self) -> Set[Connection]: raise NotImplementedError("Needs to be mocked") @overrides(Transceiver.get_cpu_infos) @@ -80,7 +81,7 @@ def get_cpu_infos( raise NotImplementedError("Needs to be mocked") @overrides(Transceiver.get_clock_drift) - def get_clock_drift(self, x, y): + def get_clock_drift(self, x: int, y: int) -> float: raise NotImplementedError("Needs to be mocked") @overrides(Transceiver.read_user) @@ -196,7 +197,7 @@ def get_tags(self, connection: Optional[SCAMPConnection] = None @overrides(Transceiver.malloc_sdram) def malloc_sdram( - self, x: int, y: int, size: int, app_id: int, tag=0) -> int: + self, x: int, y: int, size: int, app_id: int, tag: int = 0) -> int: raise NotImplementedError("Needs to be mocked") @overrides(Transceiver.load_multicast_routes) diff --git a/spinnman/transceiver/transceiver.py b/spinnman/transceiver/transceiver.py index faa361054..d33103274 100644 --- a/spinnman/transceiver/transceiver.py +++ b/spinnman/transceiver/transceiver.py @@ -16,13 +16,14 @@ from typing import ( BinaryIO, Collection, Dict, FrozenSet, Iterable, - List, Optional, Tuple, Union) + List, Optional, Set, Tuple, Union) from spinn_utilities.abstract_base import abstractmethod from spinn_utilities.progress_bar import ProgressBar from spinn_utilities.typing.coords import XY from spinn_machine import ( CoreSubsets, FixedRouteEntry, Machine, MulticastRoutingEntry) from spinn_machine.tags import AbstractTag, IPTag, ReverseIPTag +from spinnman.connections.abstract_classes import Connection from spinnman.connections.udp_packet_connections import ( SCAMPConnection, SDPConnection) from spinnman.messages.scp.enums import Signal @@ -111,7 +112,7 @@ def add_scamp_connections(self, connections: Dict[XY, str]): raise NotImplementedError("abstractmethod") @abstractmethod - def get_connections(self): + def get_connections(self) -> Set[Connection]: """ Get the currently known connections to the board, made up of those passed in to the transceiver and those that are discovered during @@ -732,7 +733,7 @@ def get_tags(self, connection: Optional[SCAMPConnection] = None @abstractmethod def malloc_sdram( - self, x: int, y: int, size: int, app_id: int, tag=0) -> int: + self, x: int, y: int, size: int, app_id: int, tag: int = 0) -> int: """ Allocates a chunk of SDRAM on a chip on the machine. From edb7332ec74d581b63d223158a1b2b4da8177007 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 19 Dec 2023 09:02:07 +0000 Subject: [PATCH 03/59] flake8 --- .../messages/eieio/command_messages/eieio_command_message.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spinnman/messages/eieio/command_messages/eieio_command_message.py b/spinnman/messages/eieio/command_messages/eieio_command_message.py index accdfe400..f28002eb5 100644 --- a/spinnman/messages/eieio/command_messages/eieio_command_message.py +++ b/spinnman/messages/eieio/command_messages/eieio_command_message.py @@ -25,7 +25,8 @@ class EIEIOCommandMessage(AbstractEIEIOMessage): "_eieio_command_header", "_offset") - def __init__(self, eieio_command_header: EIEIOCommandHeader, data=None, offset=0): + def __init__(self, eieio_command_header: EIEIOCommandHeader, data=None, + offset=0): """ :param EIEIOCommandHeader eieio_command_header: The header of the message From 9f17703735cf527f3bebe2a7c756f0fa484663af Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 19 Dec 2023 13:07:17 +0000 Subject: [PATCH 04/59] typing --- spinnman/spalloc/spalloc_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spinnman/spalloc/spalloc_client.py b/spinnman/spalloc/spalloc_client.py index 50768f206..2df61eb79 100644 --- a/spinnman/spalloc/spalloc_client.py +++ b/spinnman/spalloc/spalloc_client.py @@ -28,7 +28,7 @@ from typing import ( Any, ContextManager, Callable, Dict, FrozenSet, Iterable, Iterator, List, Mapping, - Optional, Tuple, cast) + Optional, Tuple, Union, cast) from typing_extensions import TypeAlias from websocket import WebSocket # type: ignore from spinn_utilities.abstract_base import AbstractBase, abstractmethod @@ -242,6 +242,7 @@ def create_job_rect_at_board( ip_address: Optional[str] = None, machine_name: Optional[str] = None, keepalive: int = 45, max_dead_boards: int = 0) -> SpallocJob: + board: JsonObject if triad: x, y, z = triad board = {"x": int(x), "y": int(y), "z": int(z)} From 68fd7ae53ae7164505a377bab4b487d22777283e Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 19 Dec 2023 13:22:33 +0000 Subject: [PATCH 05/59] remove unused type --- spinnman/spalloc/spalloc_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spinnman/spalloc/spalloc_client.py b/spinnman/spalloc/spalloc_client.py index 2df61eb79..31731d8d1 100644 --- a/spinnman/spalloc/spalloc_client.py +++ b/spinnman/spalloc/spalloc_client.py @@ -28,7 +28,7 @@ from typing import ( Any, ContextManager, Callable, Dict, FrozenSet, Iterable, Iterator, List, Mapping, - Optional, Tuple, Union, cast) + Optional, Tuple, cast) from typing_extensions import TypeAlias from websocket import WebSocket # type: ignore from spinn_utilities.abstract_base import AbstractBase, abstractmethod From 067ce098d3e59183dbd4cd062fe48a3a3deb2e6e Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 3 Jan 2024 09:37:39 +0000 Subject: [PATCH 06/59] fail on ANY pylint message --- .github/workflows/python_actions.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index 49fdef9ef..23737161c 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -65,6 +65,7 @@ jobs: uses: ./support/actions/pylint with: package: spinnman + exitcheck: 31 # Action fails on any message language: en_GB - name: Lint with mypy run: mypy spinnman From 3670018c6de98d67fda1d84b3d7dddb449620aab Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 3 Jan 2024 09:43:07 +0000 Subject: [PATCH 07/59] cleanup pylint exceptions --- .pylint_dict.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pylint_dict.txt b/.pylint_dict.txt index 93ab12355..b901a3fdd 100644 --- a/.pylint_dict.txt +++ b/.pylint_dict.txt @@ -14,14 +14,14 @@ # Our abbreviations/names bmp +bmpc cpu iobuf scp Spalloc -bmpc -ybug txrx url +ybug xy xys From d28c230bc753fa82298bdb43d1ad5779c1071351 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 19 Jan 2024 07:21:28 +0000 Subject: [PATCH 08/59] move deplicate spelling exceptions to default dict --- .pylint_dict.txt | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.pylint_dict.txt b/.pylint_dict.txt index b901a3fdd..9392a8031 100644 --- a/.pylint_dict.txt +++ b/.pylint_dict.txt @@ -15,33 +15,20 @@ # Our abbreviations/names bmp bmpc -cpu -iobuf -scp Spalloc -txrx -url ybug -xy -xys # Our special words keepalive -# Our special words ("wrap-arounds" gets split up) -arounds # Python packages -spinnman websocket # Python types -BMPConnectionData BufferedIOBase -CoreSubset CPUInfo CPUInfos -CPUState DiagnosticFilter DiagnosticFilterDestination DiagnosticFilterDefaultRoutingStatus @@ -49,14 +36,9 @@ DiagnosticFilterEmergencyRoutingStatus DiagnosticFilterPacketType DiagnosticFilterPayloadStatus DiagnosticFilterSource -ExecutableType HeapElement -IOBuffer PreparedRequest -RawIOBase -SCAMPConnection SCPResult -SpallocJob SpallocMachine SpinnakerBootMessage SystemVariableDefinition From fb0bf7727d8ddfc5195554c07e45b4dea92f29a5 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 19 Jan 2024 08:14:11 +0000 Subject: [PATCH 09/59] spelling fixes and exceptions --- spinnman/extended/extended_transceiver.py | 4 ++-- spinnman/messages/scp/enums/scp_command.py | 2 +- spinnman/messages/scp/impl/do_sync.py | 4 ++-- spinnman/messages/scp/impl/router_init.py | 2 +- spinnman/spalloc/spalloc_client.py | 2 +- spinnman/spalloc/spalloc_job.py | 2 +- spinnman/transceiver/base_transceiver.py | 17 ++++++++--------- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/spinnman/extended/extended_transceiver.py b/spinnman/extended/extended_transceiver.py index f65ce4ad3..1a02d62b8 100644 --- a/spinnman/extended/extended_transceiver.py +++ b/spinnman/extended/extended_transceiver.py @@ -664,7 +664,7 @@ def __set_watch_dog_on_chip(self, x, y, watch_dog): :param int x: chip X coordinate to write new watchdog parameter to :param int y: chip Y coordinate to write new watchdog parameter to :param watch_dog: - Either a boolean indicating whether to enable (True) or + Either a Boolean indicating whether to enable (True) or disable (False) the watchdog timer, or an int value to set the timer count to :type watch_dog: bool or int @@ -694,7 +694,7 @@ def set_watch_dog(self, watch_dog): Retained in case needed for hardware debugging. :param watch_dog: - Either a boolean indicating whether to enable (True) or + Either a Boolean indicating whether to enable (True) or disable (False) the watch dog timer, or an int value to set the timer count to. :type watch_dog: bool or int diff --git a/spinnman/messages/scp/enums/scp_command.py b/spinnman/messages/scp/enums/scp_command.py index 33c51e93a..94f532e46 100644 --- a/spinnman/messages/scp/enums/scp_command.py +++ b/spinnman/messages/scp/enums/scp_command.py @@ -59,7 +59,7 @@ class SCPCommand(Enum): CMD_DPRI = 30 #: Get Chip Summary Information. CMD_INFO = 31 - #: Control sending of synchronization messages. + #: Control sending of synchronisation messages. CMD_SYNC = 32 # ======== BMP ======== diff --git a/spinnman/messages/scp/impl/do_sync.py b/spinnman/messages/scp/impl/do_sync.py index ccf074150..475a2ee9a 100644 --- a/spinnman/messages/scp/impl/do_sync.py +++ b/spinnman/messages/scp/impl/do_sync.py @@ -22,13 +22,13 @@ class DoSync(AbstractSCPRequest[CheckOKResponse]): """ - An SCP Request to control synchronization. + An SCP Request to control synchronisation. """ __slots__ = () def __init__(self, do_sync: bool): """ - :param bool do_sync: Whether to synchronize or not + :param bool do_sync: Whether to synchronise or not """ super().__init__( SDPHeader( diff --git a/spinnman/messages/scp/impl/router_init.py b/spinnman/messages/scp/impl/router_init.py index ed7787699..e968eb0b7 100644 --- a/spinnman/messages/scp/impl/router_init.py +++ b/spinnman/messages/scp/impl/router_init.py @@ -23,7 +23,7 @@ class RouterInit(AbstractSCPRequest[CheckOKResponse]): """ - A request to initialize the router on a chip. + A request to initialise the router on a chip. """ __slots__ = () diff --git a/spinnman/spalloc/spalloc_client.py b/spinnman/spalloc/spalloc_client.py index 31731d8d1..71637d1dc 100644 --- a/spinnman/spalloc/spalloc_client.py +++ b/spinnman/spalloc/spalloc_client.py @@ -481,7 +481,7 @@ def dispatch_message(self, channel_id: int, msg: bytes): def unlisten(self, channel_id: int): """ - De-register a listener for a channel + Deregister a listener for a channel """ self.__handlers.pop(channel_id) diff --git a/spinnman/spalloc/spalloc_job.py b/spinnman/spalloc/spalloc_job.py index adb7b2b31..14f5ba429 100644 --- a/spinnman/spalloc/spalloc_job.py +++ b/spinnman/spalloc/spalloc_job.py @@ -200,7 +200,7 @@ def launch_keepalive_task( :param int period: How often to send a keepalive message (in seconds) :return: - Some kind of closable task handle; closing it terminates the task. + Some kind of closeable task handle; closing it terminates the task. Destroying the job will also terminate the task. """ raise NotImplementedError() diff --git a/spinnman/transceiver/base_transceiver.py b/spinnman/transceiver/base_transceiver.py index bf2a20acc..108b78b27 100644 --- a/spinnman/transceiver/base_transceiver.py +++ b/spinnman/transceiver/base_transceiver.py @@ -256,7 +256,7 @@ def __identify_connections( ) -> MostDirectConnectionSelector: for conn in connections: - # locate the only boot send conn + # locate the only boot send connection if isinstance(conn, BootConnection): if self._boot_send_connection is not None: raise SpinnmanInvalidParameterException( @@ -266,7 +266,7 @@ def __identify_connections( # Locate any connections that talk to a BMP if isinstance(conn, BMPConnection): - # If it is a BMP conn, add it here + # If it is a BMP connection, add it here if self._bmp_connection is not None: raise NotImplementedError( "Only one BMP connection supported") @@ -276,7 +276,7 @@ def __identify_connections( elif isinstance(conn, SCAMPConnection): self._scamp_connections.append(conn) - # update the transceiver with the conn selectors. + # update the transceiver with the connection selectors. return MostDirectConnectionSelector(self._scamp_connections) def __check_bmp_connection(self) -> None: @@ -285,12 +285,11 @@ def __check_bmp_connection(self) -> None: :raise SpinnmanIOException: when a connection is not linked to a BMP """ - # check that the UDP BMP conn is actually connected to a BMP - # via the sver command + # check that the UDP BMP connection is actually connected to a BMP + # via the get_scamp_version command if self._bmp_connection is not None: conn = self._bmp_connection - # try to send a BMP sver to check if it responds as expected try: version_info = self._get_scamp_version( conn.chip_x, conn.chip_y, self._bmp_selector) @@ -802,7 +801,7 @@ def get_iobuf(self, core_subsets: Optional[CoreSubsets] = None AbstractSCPRequest.DEFAULT_DEST_Y_COORD, SystemVariableDefinition.iobuf_size)) # Get all the cores if the subsets are not given - # todo is core_subsets ever None + # TODO is core_subsets ever None if core_subsets is None: core_subsets = CoreSubsets() for chip in SpiNNManDataView.get_machine().chips: @@ -848,7 +847,7 @@ def execute_flood( if isinstance(executable, int): # No executable is 4 bytes long raise TypeError("executable may not be int") - # Lock against other executable's + # Lock against other executables with self.__flood_execute_lock(): # Flood fill the system with the binary n_bytes, chksum = self.write_memory( @@ -1018,7 +1017,7 @@ def __log_where_is_info(self, cpu_infos: Iterable[ """ xys = set() for cpu_info in cpu_infos: - # todo: Is it ever not a CPUInfo + # TODO: Is it ever not a CPUInfo if isinstance(cpu_info, CPUInfo): xys.add((cpu_info.x, cpu_info.y)) else: From bd074521387e6e6b21606b29755a1cec5bc441c5 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 19 Jan 2024 08:23:52 +0000 Subject: [PATCH 10/59] remove useless doc as param is spelled wrong --- spinnman/utilities/locate_connected_machine_ip_address.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spinnman/utilities/locate_connected_machine_ip_address.py b/spinnman/utilities/locate_connected_machine_ip_address.py index 41896fce1..81454ac17 100644 --- a/spinnman/utilities/locate_connected_machine_ip_address.py +++ b/spinnman/utilities/locate_connected_machine_ip_address.py @@ -43,10 +43,9 @@ def locate_connected_machine(handler: Callable[[str, float], None]): if __name__ == "__main__": + def _ctrlc_handler(sig, frame): # @UnusedVariable """ - :param sig: - :param frame: :return: Never returns as it causes a sys.exit() """ # pylint: disable=unused-argument From a53c59afaecd48ea8d97c9708cbf5a7816c639cf Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 19 Jan 2024 10:08:19 +0000 Subject: [PATCH 11/59] spelling --- spinnman/utilities/utility_functions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spinnman/utilities/utility_functions.py b/spinnman/utilities/utility_functions.py index 901b4cf9e..1c6f99b65 100644 --- a/spinnman/utilities/utility_functions.py +++ b/spinnman/utilities/utility_functions.py @@ -99,7 +99,7 @@ def reprogram_tag(connection: SCAMPConnection, tag: int, strip: bool = True): connection.chip_x, connection.chip_y, [0, 0, 0, 0], 0, tag, strip=strip, use_sender=True) data = connection.get_scp_data(request) - exn = None + exception = None for _ in range(3): try: connection.send(data) @@ -107,9 +107,9 @@ def reprogram_tag(connection: SCAMPConnection, tag: int, strip: bool = True): request.get_scp_response().read_bytestring(response, offset) return except SpinnmanTimeoutException as e: - exn = e - # Should be impossible to get here with exn=None - raise exn or Exception + exception = e + # Should be impossible to get here with xception=None + raise exception or Exception def reprogram_tag_to_listener( From 8b69dab203cb8f0d27d83b3c42b34e1033a76553 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 19 Jan 2024 10:08:44 +0000 Subject: [PATCH 12/59] pylint bash --- pylint.bash | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 pylint.bash diff --git a/pylint.bash b/pylint.bash new file mode 100644 index 000000000..6022a1eb4 --- /dev/null +++ b/pylint.bash @@ -0,0 +1,32 @@ +#!/bin/bash + +# Copyright (c) 2024 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. + +# This bash assumes that SupportScripts has been installed in parallel + +# requires the latest pylint and pyenchant +# pip install --upgrade pylint pyenchant + +# requires the spelling dicts +# sudo apt-get -o Dpkg::Use-Pty=0 install --fix-missing enchant-2 hunspell hunspell-en-gb + +dict=/tmp/dict.txt + +cat "../SupportScripts/actions/pylint/default_dict.txt" >$dict +cat ".pylint_dict.txt" >>$dict + +pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error spinnman +#pylint --enable=wrong-spelling-in-comment --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman + From 224fb7030c040a32e347f16b4c08896817b80918 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 19 Jan 2024 10:22:12 +0000 Subject: [PATCH 13/59] remove @UnusedVariable --- spinnman/messages/eieio/command_messages/host_data_read.py | 2 +- spinnman/messages/eieio/command_messages/host_data_read_ack.py | 2 +- .../messages/eieio/command_messages/host_send_sequenced_data.py | 2 +- .../eieio/command_messages/spinnaker_request_buffers.py | 2 +- spinnman/utilities/locate_connected_machine_ip_address.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spinnman/messages/eieio/command_messages/host_data_read.py b/spinnman/messages/eieio/command_messages/host_data_read.py index 9f9016398..101edab36 100644 --- a/spinnman/messages/eieio/command_messages/host_data_read.py +++ b/spinnman/messages/eieio/command_messages/host_data_read.py @@ -81,7 +81,7 @@ def get_min_packet_length(): return 8 @staticmethod - def from_bytestring(command_header, data, offset): # @UnusedVariable + def from_bytestring(command_header, data, offset): n_requests, sequence_no = _PATTERN_BB.unpack_from(data, offset) offset += 2 diff --git a/spinnman/messages/eieio/command_messages/host_data_read_ack.py b/spinnman/messages/eieio/command_messages/host_data_read_ack.py index 73817aa9f..6a8345f25 100644 --- a/spinnman/messages/eieio/command_messages/host_data_read_ack.py +++ b/spinnman/messages/eieio/command_messages/host_data_read_ack.py @@ -38,7 +38,7 @@ def sequence_no(self): return self._sequence_no @staticmethod - def from_bytestring(command_header, data, offset): # @UnusedVariable + def from_bytestring(command_header, data, offset): sequence_no = _PATTERN_B.unpack_from(data, offset)[0] return HostDataReadAck(sequence_no) diff --git a/spinnman/messages/eieio/command_messages/host_send_sequenced_data.py b/spinnman/messages/eieio/command_messages/host_send_sequenced_data.py index 5c84ecc8b..2fa60d942 100644 --- a/spinnman/messages/eieio/command_messages/host_send_sequenced_data.py +++ b/spinnman/messages/eieio/command_messages/host_send_sequenced_data.py @@ -56,7 +56,7 @@ def get_min_packet_length(): return 4 @staticmethod - def from_bytestring(command_header, data, offset): # @UnusedVariable + def from_bytestring(command_header, data, offset): region_id, sequence_no = _PATTERN_BB.unpack_from(data, offset) eieio_data_message = read_eieio_data_message(data, offset) return HostSendSequencedData( diff --git a/spinnman/messages/eieio/command_messages/spinnaker_request_buffers.py b/spinnman/messages/eieio/command_messages/spinnaker_request_buffers.py index 662d801a2..56cd101b4 100644 --- a/spinnman/messages/eieio/command_messages/spinnaker_request_buffers.py +++ b/spinnman/messages/eieio/command_messages/spinnaker_request_buffers.py @@ -72,7 +72,7 @@ def get_min_packet_length(): return 12 @staticmethod - def from_bytestring(command_header, data, offset): # @UnusedVariable + def from_bytestring(command_header, data, offset): y, x, processor, region_id, sequence_no, space = \ _PATTERN_BBBxBBI.unpack_from(data, offset) p = (processor >> 3) & 0x1F diff --git a/spinnman/utilities/locate_connected_machine_ip_address.py b/spinnman/utilities/locate_connected_machine_ip_address.py index 41896fce1..5230f7e98 100644 --- a/spinnman/utilities/locate_connected_machine_ip_address.py +++ b/spinnman/utilities/locate_connected_machine_ip_address.py @@ -43,7 +43,7 @@ def locate_connected_machine(handler: Callable[[str, float], None]): if __name__ == "__main__": - def _ctrlc_handler(sig, frame): # @UnusedVariable + def _ctrlc_handler(sig, frame): """ :param sig: :param frame: From cd283d4837eacc5bcc2141d465e89c7f9e65fa80 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 19 Jan 2024 13:51:38 +0000 Subject: [PATCH 14/59] spelling fixes --- spinnman/connections/abstract_classes/listenable.py | 2 +- spinnman/constants.py | 2 +- spinnman/messages/eieio/eieio_type.py | 2 +- spinnman/messages/scp/enums/scp_result.py | 2 +- spinnman/messages/scp/impl/router_alloc.py | 2 +- spinnman/messages/scp/impl/sdram_alloc.py | 2 +- spinnman/messages/scp/impl/sdram_de_alloc.py | 4 ++-- spinnman/model/cpu_info.py | 1 + spinnman/model/enums/run_time_error.py | 12 ++++++------ spinnman/processes/get_machine_process.py | 10 +++++----- spinnman/spalloc/session.py | 1 - spinnman/spalloc/spalloc_client.py | 4 ++-- spinnman/utilities/utility_functions.py | 10 +++++----- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/spinnman/connections/abstract_classes/listenable.py b/spinnman/connections/abstract_classes/listenable.py index 481e03d80..901f0f337 100644 --- a/spinnman/connections/abstract_classes/listenable.py +++ b/spinnman/connections/abstract_classes/listenable.py @@ -17,7 +17,7 @@ T = TypeVar("T") -# Should inherit from Connection, but doesn't for MRO reasons +# Should inherit from Connection, but doesn't for Multiple Inheritance reasons class Listenable(Generic[T], metaclass=AbstractBase): """ An interface for connections that can listen for incoming messages. diff --git a/spinnman/constants.py b/spinnman/constants.py index 36e8ec5cb..f7b910176 100644 --- a/spinnman/constants.py +++ b/spinnman/constants.py @@ -75,7 +75,7 @@ #: Max user requested tag value MAX_TAG_ID: int = 7 -#: The range of values the BMP's 12-bit ADCs can measure. +#: The range of values the BMP 12-bit ADCs can measure. BMP_ADC_MAX: int = 1 << 12 #: Multiplier to convert from ADC value to volts for lines less than 2.5 V. diff --git a/spinnman/messages/eieio/eieio_type.py b/spinnman/messages/eieio/eieio_type.py index 51b30068c..955357a49 100644 --- a/spinnman/messages/eieio/eieio_type.py +++ b/spinnman/messages/eieio/eieio_type.py @@ -35,7 +35,7 @@ def __new__(cls, *args) -> 'EIEIOType': return obj def __init__(self, encoded_value: int, - # Optionals just to make mypy SHUT UP! + # Default values just to make mypy SHUT UP! # https://github.com/python/mypy/issues/10573 key_bytes: int = 0, payload_bytes: int = 0): self._encoded_value = encoded_value diff --git a/spinnman/messages/scp/enums/scp_result.py b/spinnman/messages/scp/enums/scp_result.py index 37b367f5b..af233ac4a 100644 --- a/spinnman/messages/scp/enums/scp_result.py +++ b/spinnman/messages/scp/enums/scp_result.py @@ -37,7 +37,7 @@ class SCPResult(Enum): RC_ROUTE = 0x87 #: Bad CPU number. RC_CPU = 0x88 - #: SHM destination dead. + #: destination dead. RC_DEAD = 0x89 #: No free Shared Memory buffers. RC_BUF = 0x8a diff --git a/spinnman/messages/scp/impl/router_alloc.py b/spinnman/messages/scp/impl/router_alloc.py index 9804465b5..26289308d 100644 --- a/spinnman/messages/scp/impl/router_alloc.py +++ b/spinnman/messages/scp/impl/router_alloc.py @@ -78,7 +78,7 @@ def __init__(self, x: int, y: int, app_id: int, n_entries: int): SCPRequestHeader(command=SCPCommand.CMD_ALLOC), argument_1=( (app_id << 8) | - AllocFree.ALLOC_ROUTING.value), # @UndefinedVariable + AllocFree.ALLOC_ROUTING.value), argument_2=n_entries) @overrides(AbstractSCPRequest.get_scp_response) diff --git a/spinnman/messages/scp/impl/sdram_alloc.py b/spinnman/messages/scp/impl/sdram_alloc.py index ad904146b..025908f28 100644 --- a/spinnman/messages/scp/impl/sdram_alloc.py +++ b/spinnman/messages/scp/impl/sdram_alloc.py @@ -112,7 +112,7 @@ def __init__(self, x: int, y: int, app_id: int, size: int, argument_1=( (extra_flag << 16) | (app_id << 8) | - AllocFree.ALLOC_SDRAM.value), # @UndefinedVariable + AllocFree.ALLOC_SDRAM.value), argument_2=size, argument_3=tag) self._size = size diff --git a/spinnman/messages/scp/impl/sdram_de_alloc.py b/spinnman/messages/scp/impl/sdram_de_alloc.py index ef8300d37..919dc7e38 100644 --- a/spinnman/messages/scp/impl/sdram_de_alloc.py +++ b/spinnman/messages/scp/impl/sdram_de_alloc.py @@ -107,7 +107,7 @@ def __init__(self, x: int, y: int, *, app_id: Optional[int] = None, SCPRequestHeader(command=SCPCommand.CMD_ALLOC), argument_1=( AllocFree. - FREE_SDRAM_BY_POINTER.value), # @UndefinedVariable + FREE_SDRAM_BY_POINTER.value), argument_2=base_address) self._read_n_blocks_freed = False else: @@ -121,7 +121,7 @@ def __init__(self, x: int, y: int, *, app_id: Optional[int] = None, argument_1=( app_id << 8 | AllocFree. - FREE_SDRAM_BY_APP_ID.value)) # @UndefinedVariable + FREE_SDRAM_BY_APP_ID.value)) self._read_n_blocks_freed = True @overrides(AbstractSCPRequest.get_scp_response) diff --git a/spinnman/model/cpu_info.py b/spinnman/model/cpu_info.py index c3508c2b9..0a98b2696 100644 --- a/spinnman/model/cpu_info.py +++ b/spinnman/model/cpu_info.py @@ -26,6 +26,7 @@ #: Corresponds to vcpu_t in sark.h _VCPU_PATTERN = struct.Struct("< 32s 3I 2B 2B 2I 2B H 3I 16s 2I 16x 4I") _vcpu_t: TypeAlias = Tuple[ + # pylint: disable=wrong-spelling-in-comment bytes, # 32s - r0-r7 int, int, int, # 3I - psr, sp, lr int, int, # 2B - RT error code, Physical CPU diff --git a/spinnman/model/enums/run_time_error.py b/spinnman/model/enums/run_time_error.py index 37bc619a2..c4ea0a83c 100644 --- a/spinnman/model/enums/run_time_error.py +++ b/spinnman/model/enums/run_time_error.py @@ -25,17 +25,17 @@ class RunTimeError(Enum): RESET = 1 #: Undefined instruction UNDEF = 2 - #: Undefined SVC or no handler + #: Undefined Supervisor Call instruction or no handler SVC = 3 #: Prefetch abort PABT = 4 #: Data abort DABT = 5 - #: Unhandled IRQ + #: Unhandled interrupt request IRQ = 6 - #: Unhandled FIQ + #: Unhandled Fast interrupt request FIQ = 7 - #: Unconfigured VIC vector + #: Unconfigured Vectored Interrupt Controller VIC = 8 #: Generic user abort ABORT = 9 @@ -45,7 +45,7 @@ class RunTimeError(Enum): DIVBY0 = 11 #: Event startup failure EVENT = 12 - #: Fatal SW error + #: Fatal Software error SWERR = 13 #: Failed to allocate IO buffer IOBUF = 14 @@ -59,5 +59,5 @@ class RunTimeError(Enum): TIMER = 18 #: API startup failure API = 19 - #: SW version conflict + #: Sark software version conflict SARK_VERSRION_INCORRECT = 20 diff --git a/spinnman/processes/get_machine_process.py b/spinnman/processes/get_machine_process.py index d49e96029..00e10fdc2 100644 --- a/spinnman/processes/get_machine_process.py +++ b/spinnman/processes/get_machine_process.py @@ -61,8 +61,8 @@ class GetMachineProcess(AbstractMultiConnectionProcess): """ __slots__ = ( "_chip_info", - # Used if there are any ignores with ip addresses - # Holds a mapping from ip to board root (x,y) + # Used if there are any ignores with IP addresses + # Holds a mapping from IP to board root (x,y) "_ethernets", # Holds a map from x,y to a set of virtual cores to ignores "_ignore_cores_map", @@ -87,7 +87,7 @@ def __init__(self, connection_selector: ConnectionSelector): # A dictionary of (x, y) -> ChipInfo self._chip_info: Dict[XY, ChipSummaryInfo] = dict() - # Set ethernets to None meaning not computed yet + # Set to None meaning not computed yet self._ethernets: Optional[Dict[str, XY]] = None # Maps between virtual and physical cores @@ -362,7 +362,7 @@ def _preprocess_ignore_cores(self, machine: Machine): :param ~spinn_machine.Machine machine: An empty machine to handle wrap-arounds """ - # Convert by ip to global + # Convert by IP to global for ignore in IgnoreCore.parse_string( get_config_str_or_none("Machine", "down_cores")): global_xy = self._ignores_local_to_global( @@ -389,7 +389,7 @@ def _preprocess_ignore_chips(self, machine: Machine): """ for ignore in IgnoreChip.parse_string( get_config_str_or_none("Machine", "down_chips")): - # Convert by ip to global + # Convert by IP to global global_xy = self._ignores_local_to_global( ignore.x, ignore.y, ignore.ip_address, machine) if global_xy is None: diff --git a/spinnman/spalloc/session.py b/spinnman/spalloc/session.py index ab3601705..6479f5ab5 100644 --- a/spinnman/spalloc/session.py +++ b/spinnman/spalloc/session.py @@ -115,7 +115,6 @@ def __init__( # TODO: extract this? pass else: - # Urgh self.__csrf_header = key self.__csrf = value diff --git a/spinnman/spalloc/spalloc_client.py b/spinnman/spalloc/spalloc_client.py index 71637d1dc..fb6296a41 100644 --- a/spinnman/spalloc/spalloc_client.py +++ b/spinnman/spalloc/spalloc_client.py @@ -524,8 +524,8 @@ def get_session_credentials_for_db(self) -> Mapping[Tuple[str, str], str]: config["SPALLOC", "job uri"] = self._url cookies, headers = self._session_credentials if "Authorization" in headers: - # We never write the auth headers themselves; we just extend the - # session + # We never write the authorisation headers themselves; + # we just extend the session del headers["Authorization"] for k, v in cookies.items(): config["COOKIE", k] = v diff --git a/spinnman/utilities/utility_functions.py b/spinnman/utilities/utility_functions.py index 1c6f99b65..9fc4f86e3 100644 --- a/spinnman/utilities/utility_functions.py +++ b/spinnman/utilities/utility_functions.py @@ -108,7 +108,7 @@ def reprogram_tag(connection: SCAMPConnection, tag: int, strip: bool = True): return except SpinnmanTimeoutException as e: exception = e - # Should be impossible to get here with xception=None + # Should be impossible to get here with Exception is None raise exception or Exception @@ -143,7 +143,7 @@ def reprogram_tag_to_listener( strip=strip, use_sender=True) request.sdp_header.update_for_send(x, y) send_data = b'\0\0' + request.bytestring - exn = None + exception = None for _ in range(3): try: connection.send_to(send_data, (ip_address, SCP_SCAMP_PORT)) @@ -152,6 +152,6 @@ def reprogram_tag_to_listener( connection.receive(), 2) return except SpinnmanTimeoutException as e: - exn = e - # Should be impossible to get here with exn=None - raise exn or Exception + exception = e + # Should be impossible to get here with exception is None + raise exception or Exception From 10481a08d2dfe187043efad278df7d8271c299ce Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 19 Jan 2024 13:54:47 +0000 Subject: [PATCH 15/59] move names to default --- pylint.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylint.bash b/pylint.bash index 6022a1eb4..dfcb0e749 100644 --- a/pylint.bash +++ b/pylint.bash @@ -27,6 +27,6 @@ dict=/tmp/dict.txt cat "../SupportScripts/actions/pylint/default_dict.txt" >$dict cat ".pylint_dict.txt" >>$dict -pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error spinnman -#pylint --enable=wrong-spelling-in-comment --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman +# pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error spinnman +pylint --enable=wrong-spelling-in-comment --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman From bcb97c840e134f9dcb1c7aaa9ff899f8528bb17e Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 19 Jan 2024 14:46:24 +0000 Subject: [PATCH 16/59] pylint: disable=invalid-name --- spinnman/constants.py | 1 + spinnman/messages/spinnaker_boot/system_variable_boot_values.py | 2 +- spinnman/model/cpu_info.py | 1 + spinnman/model/enums/sdp_ports.py | 1 + spinnman/model/enums/sdp_running_message_codes.py | 2 +- 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spinnman/constants.py b/spinnman/constants.py index f7b910176..8f6ae5b0f 100644 --- a/spinnman/constants.py +++ b/spinnman/constants.py @@ -15,6 +15,7 @@ from enum import Enum from typing import Dict, Tuple +# pylint: disable=invalid-name LOCAL_HOST = "127.0.0.1" #: the amount of time to wait in seconds between powering off and powering diff --git a/spinnman/messages/spinnaker_boot/system_variable_boot_values.py b/spinnman/messages/spinnaker_boot/system_variable_boot_values.py index 04bd528ae..8953f8594 100644 --- a/spinnman/messages/spinnaker_boot/system_variable_boot_values.py +++ b/spinnman/messages/spinnaker_boot/system_variable_boot_values.py @@ -58,7 +58,7 @@ class SystemVariableDefinition(Enum): """ Defines the system variables available. """ - + # pylint: disable=invalid-name y = _Definition( _DataType.BYTE, offset=0, doc="The y-coordinate of the chip") x = _Definition( diff --git a/spinnman/model/cpu_info.py b/spinnman/model/cpu_info.py index 0a98b2696..2feeafd2e 100644 --- a/spinnman/model/cpu_info.py +++ b/spinnman/model/cpu_info.py @@ -19,6 +19,7 @@ #: Size of `vcpu_t` in SARK. CPU_INFO_BYTES = 128 +# pylint: disable=invalid-name CPU_USER_0_START_ADDRESS = 112 #: Offset into data of byte of processor state field. STATE_FIELD_OFFSET = 48 diff --git a/spinnman/model/enums/sdp_ports.py b/spinnman/model/enums/sdp_ports.py index 078501dd7..d954d8287 100644 --- a/spinnman/model/enums/sdp_ports.py +++ b/spinnman/model/enums/sdp_ports.py @@ -15,6 +15,7 @@ from enum import Enum +# pylint: disable=invalid-name class SDP_PORTS(Enum): """ SDP port handling output buffering data streaming. diff --git a/spinnman/model/enums/sdp_running_message_codes.py b/spinnman/model/enums/sdp_running_message_codes.py index 708381d9a..a8fb84e2d 100644 --- a/spinnman/model/enums/sdp_running_message_codes.py +++ b/spinnman/model/enums/sdp_running_message_codes.py @@ -14,7 +14,7 @@ from enum import Enum - +# pylint: disable=invalid-name class SDP_RUNNING_MESSAGE_CODES(Enum): """ Codes for sending control messages to spin1_api. From a3f00c5625dba1520b07a0b5beea08d93be58646 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 19 Jan 2024 14:46:48 +0000 Subject: [PATCH 17/59] minor name changes --- pylint.bash | 2 +- spinnman/spalloc/spalloc_client.py | 4 ++-- spinnman/transceiver/base_transceiver.py | 4 ++-- spinnman/transceiver/transceiver_factory.py | 2 +- .../{virtual5Transceiver.py => virtual5transceiver.py} | 0 5 files changed, 6 insertions(+), 6 deletions(-) rename spinnman/transceiver/{virtual5Transceiver.py => virtual5transceiver.py} (100%) diff --git a/pylint.bash b/pylint.bash index dfcb0e749..0731c5993 100644 --- a/pylint.bash +++ b/pylint.bash @@ -28,5 +28,5 @@ cat "../SupportScripts/actions/pylint/default_dict.txt" >$dict cat ".pylint_dict.txt" >>$dict # pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error spinnman -pylint --enable=wrong-spelling-in-comment --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman +pylint --enable=invalid-name --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman diff --git a/spinnman/spalloc/spalloc_client.py b/spinnman/spalloc/spalloc_client.py index fb6296a41..320eb9f89 100644 --- a/spinnman/spalloc/spalloc_client.py +++ b/spinnman/spalloc/spalloc_client.py @@ -277,7 +277,7 @@ class _ProxyServiceError(IOError): """ -def _SpallocKeepalive(url, interval, term_queue, cookies, headers): +def _spalloc_keepalive(url, interval, term_queue, cookies, headers): """ Actual keepalive task implementation. Don't use directly. """ @@ -670,7 +670,7 @@ def launch_keepalive_task( if self.__keepalive_handle is not None: raise SpallocException("cannot keep job alive from two tasks") q: Queue = Queue(1) - p = Process(target=_SpallocKeepalive, args=( + p = Process(target=_spalloc_keepalive, args=( self._keepalive_url, 0 + period, q, *self._session_credentials), daemon=True) p.start() diff --git a/spinnman/transceiver/base_transceiver.py b/spinnman/transceiver/base_transceiver.py index 108b78b27..bfd7a5d05 100644 --- a/spinnman/transceiver/base_transceiver.py +++ b/spinnman/transceiver/base_transceiver.py @@ -730,11 +730,11 @@ def get_cpu_infos( @overrides(Transceiver.get_clock_drift) def get_clock_drift(self, x: int, y: int) -> float: - DRIFT_FP = 1 << 17 + drift_fp = 1 << 17 drift_b = self._get_sv_data(x, y, SystemVariableDefinition.clock_drift) drift = struct.unpack(" Date: Fri, 19 Jan 2024 15:34:40 +0000 Subject: [PATCH 18/59] docs --- pylint.bash | 2 +- spinnman/extended/extended_transceiver.py | 3 +- spinnman/messages/scp/enums/signal.py | 5 ++ .../messages/scp/impl/fixed_route_read.py | 5 ++ spinnman/messages/sdp/sdp_header.py | 5 ++ .../system_variable_boot_values.py | 18 +++++-- spinnman/model/diagnostic_filter.py | 50 +++++++++++++++++++ 7 files changed, 83 insertions(+), 5 deletions(-) diff --git a/pylint.bash b/pylint.bash index 0731c5993..ccd77c183 100644 --- a/pylint.bash +++ b/pylint.bash @@ -28,5 +28,5 @@ cat "../SupportScripts/actions/pylint/default_dict.txt" >$dict cat ".pylint_dict.txt" >>$dict # pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error spinnman -pylint --enable=invalid-name --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman +pylint --enable=missing-function-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman diff --git a/spinnman/extended/extended_transceiver.py b/spinnman/extended/extended_transceiver.py index 1a02d62b8..58ac4c347 100644 --- a/spinnman/extended/extended_transceiver.py +++ b/spinnman/extended/extended_transceiver.py @@ -574,7 +574,8 @@ def free_sdram_by_app_id(self, x, y, app_id): logger.info(self.where_is_xy(x, y)) raise - def get_router_diagnostic_filter(self, x, y, position): + def get_router_diagnostic_filter( + self, x: int, y: int, position: int) -> DiagnosticFilter: """ Gets a router diagnostic filter from a router. diff --git a/spinnman/messages/scp/enums/signal.py b/spinnman/messages/scp/enums/signal.py index c4be8198d..cd5a6f7e9 100644 --- a/spinnman/messages/scp/enums/signal.py +++ b/spinnman/messages/scp/enums/signal.py @@ -58,4 +58,9 @@ def __init__(self, value: int, signal_type: SignalType) -> None: @property def signal_type(self) -> SignalType: + """ + The "type" of the signal + + :rtype: SignalType + """ return self._signal_type diff --git a/spinnman/messages/scp/impl/fixed_route_read.py b/spinnman/messages/scp/impl/fixed_route_read.py index 4c3a5ae1b..cff00eb09 100644 --- a/spinnman/messages/scp/impl/fixed_route_read.py +++ b/spinnman/messages/scp/impl/fixed_route_read.py @@ -49,6 +49,11 @@ def read_data_bytestring(self, data: bytes, offset: int): @property def route(self) -> FixedRouteEntry: + """ + Converts this reponse into a Route + + :rtype: FixedRouteEntry + """ processor_ids: List[int] = list() for processor_id in range(26): if self._route & (1 << (6 + processor_id)) != 0: diff --git a/spinnman/messages/sdp/sdp_header.py b/spinnman/messages/sdp/sdp_header.py index 01d9b0a05..f5ea74cbd 100644 --- a/spinnman/messages/sdp/sdp_header.py +++ b/spinnman/messages/sdp/sdp_header.py @@ -325,6 +325,11 @@ def from_bytestring(data: bytes, offset: int): source_chip_x, source_chip_y) def get_physical_cpu_id(self) -> str: + """ + A String describing the physical core of the destination. + + :rtype: str + """ if SpiNNManDataView.has_machine(): chip = SpiNNManDataView.get_machine().get_chip_at( self._destination_chip_x, self._destination_chip_y) diff --git a/spinnman/messages/spinnaker_boot/system_variable_boot_values.py b/spinnman/messages/spinnaker_boot/system_variable_boot_values.py index 8953f8594..c5ab74a97 100644 --- a/spinnman/messages/spinnaker_boot/system_variable_boot_values.py +++ b/spinnman/messages/spinnaker_boot/system_variable_boot_values.py @@ -13,7 +13,7 @@ # limitations under the License. import struct -from typing import NamedTuple, Union, Optional +from typing import Any, NamedTuple, Union, Optional from enum import Enum _SYSTEM_VARIABLES_BOOT_SIZE = 128 @@ -359,11 +359,23 @@ def __init__(self): for variable in SystemVariableDefinition: self._values[variable] = variable.default - def set_value(self, system_variable_definition, value): + def set_value(self, system_variable_definition: SystemVariableDefinition, + value: Any): + """ + + :param system_variable_definition: + :param value: + :return: + """ self._values[system_variable_definition] = value @property - def bytestring(self): + def bytestring(self) -> bytes: + """ + Gets all the SystemVariableDefinition as bytes + + :rtype: bytes + """ data = b"" for sys_var in SystemVariableDefinition: data += struct.pack(sys_var.data_type.struct_code, diff --git a/spinnman/model/diagnostic_filter.py b/spinnman/model/diagnostic_filter.py index 7069f54ae..7730798cd 100644 --- a/spinnman/model/diagnostic_filter.py +++ b/spinnman/model/diagnostic_filter.py @@ -129,36 +129,78 @@ def __init__(self, enable_interrupt_on_counter_event: bool, @property def enable_interrupt_on_counter_event(self) -> bool: + """ + Returns the enable interrupt on counter event passed into + the init unchanged + + Currently unused + """ return self._enable_interrupt_on_counter_event @property def match_emergency_routing_status_to_incoming_packet(self) -> bool: + """ + Returns the match emergency routing status to incoming packet passed + into the init unchanged + + Currently unused + """ return self._match_emergency_routing_status_to_incoming_packet @property def destinations(self) -> List[DiagnosticFilterDestination]: + """ + Returns the destinations passed into the init unchanged + + Currently unused + """ return self._destinations @property def sources(self) -> List[DiagnosticFilterSource]: + """ + Returns the sources passed into the init unchanged + + Currently unused + """ return self._sources @property def payload_statuses(self) -> List[DiagnosticFilterPayloadStatus]: + """ + Returns the payload statuses passed into the init unchanged + + Currently unused + """ return self._payload_statuses @property def default_routing_statuses(self) -> List[ DiagnosticFilterDefaultRoutingStatus]: + """ + Returns the default routing statuses passed into the init unchanged + + Currently unused + """ return self._default_routing_statuses @property def emergency_routing_statuses(self) -> List[ DiagnosticFilterEmergencyRoutingStatus]: + """ + Returns the emergency routing statuses passed into the init unchanged + + Currently unused + """ return self._emergency_routing_statuses @property def packet_types(self) -> List[DiagnosticFilterPacketType]: + """ + Returns the packet types passed into the init unchanged + + Currently unused + """ return self._packet_types @property @@ -194,6 +236,14 @@ def filter_word(self) -> int: @staticmethod def read_from_int(int_value: int) -> DiagnosticFilter: + """ + Claims to returns a filter that reads an int + + Currently only called by unused Transceiver methods + + :param int int_value: + :rtype: DiagnosticFilter + """ enable_interrupt_on_counter_event = ( (int_value >> _ENABLE_INTERRUPT_OFFSET) & 0x1) == 1 match_emergency_routing_status_to_incoming_packet = ( From 357f55f9742a3a41bcb84c38a1c7b7e79db5fafe Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 29 Jan 2024 07:01:24 +0000 Subject: [PATCH 19/59] flake8 --- spinnman/model/enums/sdp_running_message_codes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/spinnman/model/enums/sdp_running_message_codes.py b/spinnman/model/enums/sdp_running_message_codes.py index a8fb84e2d..8e16abe92 100644 --- a/spinnman/model/enums/sdp_running_message_codes.py +++ b/spinnman/model/enums/sdp_running_message_codes.py @@ -14,6 +14,7 @@ from enum import Enum + # pylint: disable=invalid-name class SDP_RUNNING_MESSAGE_CODES(Enum): """ From da5d03fb2ee03f4305b7327863a692945ede44e9 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 29 Jan 2024 09:56:16 +0000 Subject: [PATCH 20/59] add overrides --- .../messages/eieio/command_messages/host_data_read_ack.py | 4 ++++ .../eieio/command_messages/spinnaker_request_buffers.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/spinnman/messages/eieio/command_messages/host_data_read_ack.py b/spinnman/messages/eieio/command_messages/host_data_read_ack.py index 6a8345f25..86de11bd8 100644 --- a/spinnman/messages/eieio/command_messages/host_data_read_ack.py +++ b/spinnman/messages/eieio/command_messages/host_data_read_ack.py @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. + import struct +from spinn_utilities.overrides import overrides from .eieio_command_message import EIEIOCommandMessage from .eieio_command_header import EIEIOCommandHeader from spinnman.constants import EIEIO_COMMAND_IDS @@ -38,12 +40,14 @@ def sequence_no(self): return self._sequence_no @staticmethod + @overrides(EIEIOCommandMessage.from_bytestring) def from_bytestring(command_header, data, offset): sequence_no = _PATTERN_B.unpack_from(data, offset)[0] return HostDataReadAck(sequence_no) @property + @overrides(EIEIOCommandMessage.bytestring) def bytestring(self): byte_string = super().bytestring byte_string += _PATTERN_B.pack(self.sequence_no) diff --git a/spinnman/messages/eieio/command_messages/spinnaker_request_buffers.py b/spinnman/messages/eieio/command_messages/spinnaker_request_buffers.py index 56cd101b4..e03bf5efe 100644 --- a/spinnman/messages/eieio/command_messages/spinnaker_request_buffers.py +++ b/spinnman/messages/eieio/command_messages/spinnaker_request_buffers.py @@ -13,6 +13,7 @@ # limitations under the License. import struct +from spinn_utilities.overrides import overrides from .eieio_command_message import EIEIOCommandMessage from .eieio_command_header import EIEIOCommandHeader from spinnman.constants import EIEIO_COMMAND_IDS @@ -68,10 +69,12 @@ def space_available(self): return self._space_available @staticmethod + @overrides(EIEIOCommandMessage.get_min_packet_length) def get_min_packet_length(): return 12 @staticmethod + @overrides(EIEIOCommandMessage.from_bytestring) def from_bytestring(command_header, data, offset): y, x, processor, region_id, sequence_no, space = \ _PATTERN_BBBxBBI.unpack_from(data, offset) @@ -80,6 +83,7 @@ def from_bytestring(command_header, data, offset): x, y, p, region_id & 0xF, sequence_no, space) @property + @overrides(EIEIOCommandMessage.bytestring) def bytestring(self): return (super().bytestring + _PATTERN_BBBxBBI.pack( self._y, self._x, self._p << 3, self._region_id, From 15dfe1ad3bf1f484d96ecfaaec9e01881d427ffd Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 29 Jan 2024 11:17:31 +0000 Subject: [PATCH 21/59] docs --- .../command_messages/host_data_read_ack.py | 13 +++- .../notification_protocol_db_location.py | 10 ++- .../spinnaker_request_buffers.py | 55 ++++++++++++-- .../eieio/data_messages/eieio_data_header.py | 73 ++++++++++++++++--- .../eieio/data_messages/key_data_element.py | 5 ++ .../data_messages/key_payload_data_element.py | 18 ++++- .../system_variable_boot_values.py | 34 ++++++++- 7 files changed, 187 insertions(+), 21 deletions(-) diff --git a/spinnman/messages/eieio/command_messages/host_data_read_ack.py b/spinnman/messages/eieio/command_messages/host_data_read_ack.py index 86de11bd8..83a504bd6 100644 --- a/spinnman/messages/eieio/command_messages/host_data_read_ack.py +++ b/spinnman/messages/eieio/command_messages/host_data_read_ack.py @@ -30,13 +30,22 @@ class HostDataReadAck(EIEIOCommandMessage): """ __slots__ = "_sequence_no", - def __init__(self, sequence_no): + def __init__(self, sequence_no: int): + """ + + :param int sequence_no: + """ super().__init__( EIEIOCommandHeader(EIEIO_COMMAND_IDS.HOST_DATA_READ_ACK)) self._sequence_no = sequence_no @property - def sequence_no(self): + def sequence_no(self) -> int: + """ + Gets the sequence_no passed into the init. + + :rtype: int + """ return self._sequence_no @staticmethod diff --git a/spinnman/messages/eieio/command_messages/notification_protocol_db_location.py b/spinnman/messages/eieio/command_messages/notification_protocol_db_location.py index 1c8dcefe1..cb6c7f607 100644 --- a/spinnman/messages/eieio/command_messages/notification_protocol_db_location.py +++ b/spinnman/messages/eieio/command_messages/notification_protocol_db_location.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from typing import Optional from .eieio_command_message import EIEIOCommandMessage from .eieio_command_header import EIEIOCommandHeader from spinnman.constants import EIEIO_COMMAND_IDS @@ -40,7 +41,14 @@ def __init__(self, database_path=None): self._database_path = database_path.encode() @property - def database_path(self): + def database_path(self) -> Optional[str]: + """ + Gets the database path passed into the init. + + The path is encoded by the init and decode back to a str here. + + :rtype: str + """ if self._database_path is not None: return self._database_path.decode() else: diff --git a/spinnman/messages/eieio/command_messages/spinnaker_request_buffers.py b/spinnman/messages/eieio/command_messages/spinnaker_request_buffers.py index e03bf5efe..1839dc75a 100644 --- a/spinnman/messages/eieio/command_messages/spinnaker_request_buffers.py +++ b/spinnman/messages/eieio/command_messages/spinnaker_request_buffers.py @@ -33,7 +33,18 @@ class SpinnakerRequestBuffers(EIEIOCommandMessage): "_space_available", "_p", "_x", "_y") - def __init__(self, x, y, p, region_id, sequence_no, space_available): + def __init__( + self, x: int, y: int, p: int, region_id: int, sequence_no: int, + space_available: int): + """ + + :param int x: + :param int y: + :param int p: + :param int region_id: + :param int sequence_no: + :param int space_available: + """ # pylint: disable=too-many-arguments super().__init__(EIEIOCommandHeader( EIEIO_COMMAND_IDS.SPINNAKER_REQUEST_BUFFERS)) @@ -45,27 +56,57 @@ def __init__(self, x, y, p, region_id, sequence_no, space_available): self._space_available = space_available @property - def x(self): + def x(self) -> int: + """ + Gets the x value passed into the init + + :rtype: int + """ return self._x @property - def y(self): + def y(self) -> int: + """ + Gets the y value passed into the init + + :rtype: int + """ return self._y @property - def p(self): + def p(self) -> int: + """ + Gets the p value passed into the init + + :rtype: int + """ return self._p @property - def region_id(self): + def region_id(self) -> int: + """ + Gets the region_id value passed into the init + + :rtype: int + """ return self._region_id @property - def sequence_no(self): + def sequence_no(self) -> int: + """ + Gets the sequence_no value passed into the init + + :rtype: int + """ return self._sequence_no @property - def space_available(self): + def space_available(self) -> int: + """ + Gets the space_available value passed into the init + + :rtype: int + """ return self._space_available @staticmethod diff --git a/spinnman/messages/eieio/data_messages/eieio_data_header.py b/spinnman/messages/eieio/data_messages/eieio_data_header.py index ce2be76d2..3af498bbf 100644 --- a/spinnman/messages/eieio/data_messages/eieio_data_header.py +++ b/spinnman/messages/eieio/data_messages/eieio_data_header.py @@ -13,6 +13,8 @@ # limitations under the License. import struct +from typing import Optional + from spinnman.messages.eieio import EIEIOType, EIEIOPrefix from spinnman.exceptions import SpinnmanInvalidPacketException @@ -37,9 +39,11 @@ class EIEIODataHeader(object): "_prefix_type", "_tag") - def __init__(self, eieio_type, tag=0, prefix=None, - prefix_type=EIEIOPrefix.LOWER_HALF_WORD, - payload_base=None, is_time=False, count=0): + def __init__(self, eieio_type: EIEIOType, tag: int = 0, + prefix: Optional[int] = None, + prefix_type: EIEIOPrefix = EIEIOPrefix.LOWER_HALF_WORD, + payload_base: Optional[int] = None, is_time: bool = False, + count: int = 0): """ EIEIO header for data packets. @@ -67,39 +71,84 @@ def __init__(self, eieio_type, tag=0, prefix=None, self._count = count @property - def eieio_type(self): + def eieio_type(self) -> EIEIOType: + """ + Gets the eieio_type passed into the init. + + :rtype: EIEIOType + """ return self._eieio_type @property - def tag(self): + def tag(self) -> int: + """ + Gets the tag value passed into the init. + + :rtype: int + """ return self._tag @property - def prefix(self): + def prefix(self) -> Optional[int]: + """ + Gets prefix passed into the init (if applicable). + + :rtype: int or None + """ return self._prefix @property - def prefix_type(self): + def prefix_type(self) -> EIEIOPrefix: + """ + Gets the prefix_type passed into the init. + + :rtype: EIEIOPrefix + """ return self._prefix_type @property - def payload_base(self): + def payload_base(self) -> Optional[int]: + """ + Gets the payload_base value passed into the init (if applicable). + + :rtype: int or None + """ return self._payload_base @property def is_time(self) -> bool: + """ + Gets the is_time value passed into the init. + + :rtype: bool + """ return self._is_time @property def count(self) -> int: + """ + Count of the number of items in the packet + + :rtype: int + """ return self._count @count.setter - def count(self, count): + def count(self, count: int): + """ + Sets the Count of the number of items in the packet + + :param int count: the new value + """ self._count = count @property def size(self) -> int: + """ + Get the size of a header with the given parameters. + + :rtype: int + """ return EIEIODataHeader.get_header_size( self._eieio_type, self._prefix is not None, self._payload_base is not None) @@ -124,9 +173,15 @@ def get_header_size(eieio_type, is_prefix=False, is_payload_base=False): return size def increment_count(self) -> None: + """ + Increase the count by 1. + """ self._count += 1 def reset_count(self) -> None: + """ + Resets the count back to zero. + """ self._count = 0 @property diff --git a/spinnman/messages/eieio/data_messages/key_data_element.py b/spinnman/messages/eieio/data_messages/key_data_element.py index 9122264df..8ba2c6237 100644 --- a/spinnman/messages/eieio/data_messages/key_data_element.py +++ b/spinnman/messages/eieio/data_messages/key_data_element.py @@ -33,6 +33,11 @@ def __init__(self, key: int): @property def key(self) -> int: + """ + The key value passed into the init. + + :rtype: int + """ return self._key @overrides(AbstractDataElement.get_bytestring) diff --git a/spinnman/messages/eieio/data_messages/key_payload_data_element.py b/spinnman/messages/eieio/data_messages/key_payload_data_element.py index 9831e7232..252cce6a7 100644 --- a/spinnman/messages/eieio/data_messages/key_payload_data_element.py +++ b/spinnman/messages/eieio/data_messages/key_payload_data_element.py @@ -31,21 +31,37 @@ class KeyPayloadDataElement(AbstractDataElement): "_payload", "_payload_is_timestamp") - def __init__(self, key: int, payload: int, payload_is_timestamp=False): + def __init__( + self, key: int, payload: int, payload_is_timestamp: bool = False): self._key = key self._payload = payload self._payload_is_timestamp = payload_is_timestamp @property def key(self) -> int: + """ + The key value passed into the init. + + :rtype: int + """ return self._key @property def payload(self) -> int: + """ + Gets the payload value passed into the init. + + :rtype: int + """ return self._payload @property def payload_is_timestamp(self) -> bool: + """ + Gets the payload_is_timestamp passed into the init. + + :rtype: int + """ return self._payload_is_timestamp @overrides(AbstractDataElement.get_bytestring) diff --git a/spinnman/messages/spinnaker_boot/system_variable_boot_values.py b/spinnman/messages/spinnaker_boot/system_variable_boot_values.py index c5ab74a97..aca5c767a 100644 --- a/spinnman/messages/spinnaker_boot/system_variable_boot_values.py +++ b/spinnman/messages/spinnaker_boot/system_variable_boot_values.py @@ -35,10 +35,20 @@ def __init__(self, value, struct_code): @property def struct_code(self) -> str: + """ + Gets the struct_code value passed into the init + + :rtype: str + """ return self._struct_code @property def is_byte_array(self) -> bool: + """ + Detects if enum is a BYTE_ARRAY without exposing the Class + + :rtype: bool + """ # can't use BYTE_ARRAY.value directly here return self._value_ == 16 @@ -331,18 +341,38 @@ def __init__( @property def data_type(self) -> _DataType: + """ + Gets the data_type passed into the init. + + :rtype: _DataType + """ return self._data_type @property def array_size(self) -> Optional[int]: + """ + Gets the array size passed into the init (if applicable) + + :rtype: int or None + """ return self._array_size @property def offset(self) -> int: + """ + Gets the Offset passed into the init + + :rtype: int + """ return self._offset @property def default(self) -> Union[int, bytes]: + """ + Gets the default Value passed into the init + + :rtype: int or bytes + """ return self._default @@ -362,8 +392,10 @@ def __init__(self): def set_value(self, system_variable_definition: SystemVariableDefinition, value: Any): """ + Save a value to the system_variable_definition Enum as the key - :param system_variable_definition: + :param system_variable_definition: Key to save value with + :type system_variable_definition: SystemVariableDefinition :param value: :return: """ From 9967d09259a02dea44154a2be29b2513f7a30194 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 29 Jan 2024 11:38:37 +0000 Subject: [PATCH 22/59] spelling --- spinnman/messages/scp/impl/fixed_route_read.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spinnman/messages/scp/impl/fixed_route_read.py b/spinnman/messages/scp/impl/fixed_route_read.py index cff00eb09..8ddfa7a5c 100644 --- a/spinnman/messages/scp/impl/fixed_route_read.py +++ b/spinnman/messages/scp/impl/fixed_route_read.py @@ -50,7 +50,7 @@ def read_data_bytestring(self, data: bytes, offset: int): @property def route(self) -> FixedRouteEntry: """ - Converts this reponse into a Route + Converts this response into a Route :rtype: FixedRouteEntry """ From ebed7a1379fe069408b8c655ea4962e99ceda53c Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 29 Jan 2024 11:51:01 +0000 Subject: [PATCH 23/59] add overrides --- .../eieio/command_messages/host_send_sequenced_data.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spinnman/messages/eieio/command_messages/host_send_sequenced_data.py b/spinnman/messages/eieio/command_messages/host_send_sequenced_data.py index 2fa60d942..78b67bc01 100644 --- a/spinnman/messages/eieio/command_messages/host_send_sequenced_data.py +++ b/spinnman/messages/eieio/command_messages/host_send_sequenced_data.py @@ -13,6 +13,7 @@ # limitations under the License. import struct +from spinn_utilities.overrides import overrides from .eieio_command_message import EIEIOCommandMessage from .eieio_command_header import EIEIOCommandHeader from spinnman.constants import EIEIO_COMMAND_IDS @@ -52,10 +53,12 @@ def eieio_data_message(self): return self._eieio_data_message @staticmethod + @overrides(EIEIOCommandMessage.get_min_packet_length) def get_min_packet_length(): return 4 @staticmethod + @overrides(EIEIOCommandMessage.from_bytestring) def from_bytestring(command_header, data, offset): region_id, sequence_no = _PATTERN_BB.unpack_from(data, offset) eieio_data_message = read_eieio_data_message(data, offset) @@ -63,6 +66,7 @@ def from_bytestring(command_header, data, offset): region_id, sequence_no, eieio_data_message) @property + @overrides(EIEIOCommandMessage.bytestring) def bytestring(self): return (super().bytestring + _PATTERN_BB.pack(self._region_id, self._sequence_no) + From 53d08e4187bb1c08d3409bf8dce4c6085fad9320 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 29 Jan 2024 12:05:50 +0000 Subject: [PATCH 24/59] docs --- .../command_messages/eieio_command_header.py | 15 +++++++-- .../command_messages/eieio_command_message.py | 1 - .../host_send_sequenced_data.py | 32 ++++++++++++++++--- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/spinnman/messages/eieio/command_messages/eieio_command_header.py b/spinnman/messages/eieio/command_messages/eieio_command_header.py index 482a5a5cd..6d9265c19 100644 --- a/spinnman/messages/eieio/command_messages/eieio_command_header.py +++ b/spinnman/messages/eieio/command_messages/eieio_command_header.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from typing import Union import struct from enum import Enum from spinnman.exceptions import SpinnmanInvalidParameterException @@ -25,7 +26,12 @@ class EIEIOCommandHeader(object): """ __slots__ = "_command", - def __init__(self, command): + def __init__(self, command: Union[int, Enum]): + """ + + :param command: + :type command: int or Enum + """ if isinstance(command, Enum): command = command.value if command < 0 or command >= 16384: @@ -35,7 +41,12 @@ def __init__(self, command): self._command = command @property - def command(self): + def command(self) -> int: + """ + The command/ value of the command passed into the init. + + :rtype: int + """ return self._command @staticmethod diff --git a/spinnman/messages/eieio/command_messages/eieio_command_message.py b/spinnman/messages/eieio/command_messages/eieio_command_message.py index f28002eb5..97b6e4494 100644 --- a/spinnman/messages/eieio/command_messages/eieio_command_message.py +++ b/spinnman/messages/eieio/command_messages/eieio_command_message.py @@ -61,7 +61,6 @@ def from_bytestring(command_header, data, offset): return EIEIOCommandMessage(command_header, data, offset) @property - @overrides(AbstractEIEIOMessage.bytestring) def bytestring(self) -> bytes: return self._eieio_command_header.bytestring diff --git a/spinnman/messages/eieio/command_messages/host_send_sequenced_data.py b/spinnman/messages/eieio/command_messages/host_send_sequenced_data.py index 78b67bc01..1ba6442df 100644 --- a/spinnman/messages/eieio/command_messages/host_send_sequenced_data.py +++ b/spinnman/messages/eieio/command_messages/host_send_sequenced_data.py @@ -17,8 +17,10 @@ from .eieio_command_message import EIEIOCommandMessage from .eieio_command_header import EIEIOCommandHeader from spinnman.constants import EIEIO_COMMAND_IDS +from spinnman.messages.eieio import AbstractEIEIOMessage from spinnman.messages.eieio.create_eieio_data import read_eieio_data_message + _PATTERN_BB = struct.Struct(" int: + """ + The region_id passed into the init. + + :rtype: int + """ return self._region_id @property - def sequence_no(self): + def sequence_no(self) -> int: + """ + The sequence_no passed into the init. + + :rtype: int + """ return self._sequence_no @property - def eieio_data_message(self): + def eieio_data_message(self) -> AbstractEIEIOMessage: + """ + The eieio_data_message passed into the init. + + :return: AbstractEIEIOMessage + """ return self._eieio_data_message @staticmethod From ac508f4da34ce71dedbf6fdef32de7bfba31d193 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 29 Jan 2024 12:59:02 +0000 Subject: [PATCH 25/59] docs and typing --- .../command_messages/eieio_command_header.py | 4 +- .../command_messages/eieio_command_message.py | 45 ++++++++++++++++--- .../command_messages/host_data_read_ack.py | 5 ++- .../host_send_sequenced_data.py | 7 +-- .../spinnaker_request_buffers.py | 7 +-- 5 files changed, 52 insertions(+), 16 deletions(-) diff --git a/spinnman/messages/eieio/command_messages/eieio_command_header.py b/spinnman/messages/eieio/command_messages/eieio_command_header.py index 6d9265c19..d5e96fecf 100644 --- a/spinnman/messages/eieio/command_messages/eieio_command_header.py +++ b/spinnman/messages/eieio/command_messages/eieio_command_header.py @@ -50,7 +50,7 @@ def command(self) -> int: return self._command @staticmethod - def from_bytestring(data, offset): + def from_bytestring(data: bytes, offset: int) -> "EIEIOCommandHeader": """ Read an EIEIO command header from a byte-string. @@ -70,7 +70,7 @@ def from_bytestring(data, offset): return EIEIOCommandHeader(command) @property - def bytestring(self): + def bytestring(self) -> bytes: """ The byte-string of the header. diff --git a/spinnman/messages/eieio/command_messages/eieio_command_message.py b/spinnman/messages/eieio/command_messages/eieio_command_message.py index 97b6e4494..b3ccc48b4 100644 --- a/spinnman/messages/eieio/command_messages/eieio_command_message.py +++ b/spinnman/messages/eieio/command_messages/eieio_command_message.py @@ -11,6 +11,8 @@ # 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 Optional from spinn_utilities.overrides import overrides from spinnman.messages.eieio import AbstractEIEIOMessage from spinnman.messages.eieio.command_messages import EIEIOCommandHeader @@ -25,8 +27,8 @@ class EIEIOCommandMessage(AbstractEIEIOMessage): "_eieio_command_header", "_offset") - def __init__(self, eieio_command_header: EIEIOCommandHeader, data=None, - offset=0): + def __init__(self, eieio_command_header: EIEIOCommandHeader, + data: Optional[bytes] = None, offset: int = 0): """ :param EIEIOCommandHeader eieio_command_header: The header of the message @@ -44,28 +46,59 @@ def __init__(self, eieio_command_header: EIEIOCommandHeader, data=None, @overrides(AbstractEIEIOMessage.eieio_header) def eieio_header(self) -> EIEIOCommandHeader: """ + Gets the eieio_header passed into the init. + :rtype: EIEIOCommandHeader """ return self._eieio_command_header @property - def data(self): + def data(self) -> Optional[bytes]: + """ + Gets the data passed into the init (if applicable). + + :rtype: bytes or None + """ return self._data @property - def offset(self): + def offset(self) -> int: + """ + Gets the offset passed into the init + + :rtype: int + """ return self._offset @staticmethod - def from_bytestring(command_header, data, offset): + def from_bytestring(command_header: EIEIOCommandHeader, data: bytes, + offset: int) -> "EIEIOCommandMessage": + """ + Creates an EIEIOCommandMessage based on the supplied information. + + :param EIEIOCommandHeader command_header: + :param bytes data: + :param int offset: + :rtype: EIEIOCommandMessage + """ return EIEIOCommandMessage(command_header, data, offset) @property def bytestring(self) -> bytes: + """ + The eieio_command_header passed into the init as a byte string. + + :rtype: bytes + """ return self._eieio_command_header.bytestring @staticmethod - def get_min_packet_length(): + def get_min_packet_length() -> int: + """ + Gets the min packet length for this type. + + :rtype: int + """ return 2 def __str__(self): diff --git a/spinnman/messages/eieio/command_messages/host_data_read_ack.py b/spinnman/messages/eieio/command_messages/host_data_read_ack.py index 83a504bd6..f8b4e6a9f 100644 --- a/spinnman/messages/eieio/command_messages/host_data_read_ack.py +++ b/spinnman/messages/eieio/command_messages/host_data_read_ack.py @@ -50,14 +50,15 @@ def sequence_no(self) -> int: @staticmethod @overrides(EIEIOCommandMessage.from_bytestring) - def from_bytestring(command_header, data, offset): + def from_bytestring(command_header: EIEIOCommandHeader, data: bytes, + offset: int) -> "HostDataReadAck": sequence_no = _PATTERN_B.unpack_from(data, offset)[0] return HostDataReadAck(sequence_no) @property @overrides(EIEIOCommandMessage.bytestring) - def bytestring(self): + def bytestring(self) -> bytes: byte_string = super().bytestring byte_string += _PATTERN_B.pack(self.sequence_no) return byte_string diff --git a/spinnman/messages/eieio/command_messages/host_send_sequenced_data.py b/spinnman/messages/eieio/command_messages/host_send_sequenced_data.py index 1ba6442df..7ab2df256 100644 --- a/spinnman/messages/eieio/command_messages/host_send_sequenced_data.py +++ b/spinnman/messages/eieio/command_messages/host_send_sequenced_data.py @@ -78,12 +78,13 @@ def eieio_data_message(self) -> AbstractEIEIOMessage: @staticmethod @overrides(EIEIOCommandMessage.get_min_packet_length) - def get_min_packet_length(): + def get_min_packet_length() -> int: return 4 @staticmethod @overrides(EIEIOCommandMessage.from_bytestring) - def from_bytestring(command_header, data, offset): + def from_bytestring(command_header: EIEIOCommandHeader, data: bytes, + offset: int) -> "HostSendSequencedData": region_id, sequence_no = _PATTERN_BB.unpack_from(data, offset) eieio_data_message = read_eieio_data_message(data, offset) return HostSendSequencedData( @@ -91,7 +92,7 @@ def from_bytestring(command_header, data, offset): @property @overrides(EIEIOCommandMessage.bytestring) - def bytestring(self): + def bytestring(self) -> bytes: return (super().bytestring + _PATTERN_BB.pack(self._region_id, self._sequence_no) + self._eieio_data_message.bytestring) diff --git a/spinnman/messages/eieio/command_messages/spinnaker_request_buffers.py b/spinnman/messages/eieio/command_messages/spinnaker_request_buffers.py index 1839dc75a..862bf6277 100644 --- a/spinnman/messages/eieio/command_messages/spinnaker_request_buffers.py +++ b/spinnman/messages/eieio/command_messages/spinnaker_request_buffers.py @@ -111,12 +111,13 @@ def space_available(self) -> int: @staticmethod @overrides(EIEIOCommandMessage.get_min_packet_length) - def get_min_packet_length(): + def get_min_packet_length() -> int: return 12 @staticmethod @overrides(EIEIOCommandMessage.from_bytestring) - def from_bytestring(command_header, data, offset): + def from_bytestring(command_header: EIEIOCommandHeader, data: bytes, + offset: int) -> "SpinnakerRequestBuffers": y, x, processor, region_id, sequence_no, space = \ _PATTERN_BBBxBBI.unpack_from(data, offset) p = (processor >> 3) & 0x1F @@ -125,7 +126,7 @@ def from_bytestring(command_header, data, offset): @property @overrides(EIEIOCommandMessage.bytestring) - def bytestring(self): + def bytestring(self) -> bytes: return (super().bytestring + _PATTERN_BBBxBBI.pack( self._y, self._x, self._p << 3, self._region_id, self._sequence_no, self._space_available)) From 71815ff7495cc6c95f1d54979af8ba7ef839901e Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 29 Jan 2024 13:41:20 +0000 Subject: [PATCH 26/59] add overrides --- .../command_messages/spinnaker_request_read_data.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/spinnman/messages/eieio/command_messages/spinnaker_request_read_data.py b/spinnman/messages/eieio/command_messages/spinnaker_request_read_data.py index 374ae2a8f..50d4e76e4 100644 --- a/spinnman/messages/eieio/command_messages/spinnaker_request_read_data.py +++ b/spinnman/messages/eieio/command_messages/spinnaker_request_read_data.py @@ -13,6 +13,7 @@ # limitations under the License. import struct +from spinn_utilities.overrides import overrides from spinnman.exceptions import ( SpinnmanInvalidPacketException, SpinnmanInvalidParameterTypeException) from .eieio_command_message import EIEIOCommandMessage @@ -104,11 +105,14 @@ def space_to_be_read(self, request_id): return self._requests.space_to_be_read(request_id) @staticmethod - def get_min_packet_length(): + @overrides(EIEIOCommandMessage.get_min_packet_length) + def get_min_packet_length() -> int: return 16 @staticmethod - def from_bytestring(command_header, data, offset): + @overrides(EIEIOCommandMessage.from_bytestring) + def from_bytestring(command_header: EIEIOCommandHeader, data: bytes, + offset: int) -> "SpinnakerRequestReadData": (y, x, processor_and_requests, sequence_no) = \ _PATTERN_BBBB.unpack_from(data, offset) p = (processor_and_requests >> 3) & 0x1F @@ -139,7 +143,8 @@ def from_bytestring(command_header, data, offset): start_address, space_to_be_read) @property - def bytestring(self): + @overrides(EIEIOCommandMessage.bytestring) + def bytestring(self) -> bytes: byte_string = super().bytestring byte_string += _PATTERN_BB.pack(self.x, self.y) n_requests = self.n_requests From b372b541c4d4654164d56214de1c77b04c608458 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 30 Jan 2024 07:24:32 +0000 Subject: [PATCH 27/59] docs and typing --- pylint.bash | 2 +- .../eieio/command_messages/host_data_read.py | 124 +++++++++-- .../spinnaker_request_read_data.py | 197 ++++++++++++++++-- 3 files changed, 287 insertions(+), 36 deletions(-) diff --git a/pylint.bash b/pylint.bash index ccd77c183..065f0ae89 100644 --- a/pylint.bash +++ b/pylint.bash @@ -28,5 +28,5 @@ cat "../SupportScripts/actions/pylint/default_dict.txt" >$dict cat ".pylint_dict.txt" >>$dict # pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error spinnman -pylint --enable=missing-function-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman +pylint --enable=missing-function-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman diff --git a/spinnman/messages/eieio/command_messages/host_data_read.py b/spinnman/messages/eieio/command_messages/host_data_read.py index 101edab36..770d4f922 100644 --- a/spinnman/messages/eieio/command_messages/host_data_read.py +++ b/spinnman/messages/eieio/command_messages/host_data_read.py @@ -13,6 +13,7 @@ # limitations under the License. import struct +from typing import List, Union from spinnman.exceptions import ( SpinnmanInvalidPacketException, SpinnmanInvalidParameterTypeException) from .eieio_command_message import EIEIOCommandMessage @@ -35,7 +36,20 @@ class HostDataRead(EIEIOCommandMessage): "_header") def __init__( - self, n_requests, sequence_no, channel, region_id, space_read): + self, n_requests: int, sequence_no: int, + channel: Union[List[int], int], region_id: Union[List[int], int], + space_read: Union[List[int], int]): + """ + + :param int n_requests: + :param int sequence_no: + :param channel: + :type channel: list(int) or int + :param region_id: + :type region_id: list(int) or int + :param space_read: + :type space_read: list(int) or int + """ # pylint: disable=too-many-arguments if not isinstance(channel, list): channel = [channel] @@ -60,20 +74,54 @@ def __init__( self._acks = _HostDataReadAck(channel, region_id, space_read) @property - def n_requests(self): + def n_requests(self) -> int: + """ + Gets the n_requests passed into the init. + + :rtype: int + """ return self._header.n_requests @property - def sequence_no(self): + def sequence_no(self) -> int: + """ + Gets the sequence_no passed into the init. + + :rtype: int + """ return self._header.sequence_no - def channel(self, ack_id): + def channel(self, ack_id: int) -> int: + """ + Gets the channel value for this ack_id. + + :param int ack_id: + :rtype: int + :raises SpinnmanInvalidParameterTypeException: + If the ack_id is invalid + """ return self._acks.channel(ack_id) - def region_id(self, ack_id): + def region_id(self, ack_id: int) -> int: + """ + Gets the region_id value for this ack_id. + + :param int ack_id: + :rtype: int + :raises SpinnmanInvalidParameterTypeException: + If the ack_id is invalid + """ return self._acks.region_id(ack_id) - def space_read(self, ack_id): + def space_read(self, ack_id: int) -> int: + """ + Gets the space_read value for this ack_id. + + :param int ack_id: + :rtype: int + :raises SpinnmanInvalidParameterTypeException: + If the ack_id is invalid + """ return self._acks.space_read(ack_id) @staticmethod @@ -120,16 +168,31 @@ class _HostDataReadHeader(object): "_n_requests", "_sequence_no"] - def __init__(self, n_requests, sequence_no): + def __init__(self, n_requests: int, sequence_no: int): + """ + + :param int n_requests: + :param int sequence_no: + """ self._n_requests = n_requests self._sequence_no = sequence_no @property - def sequence_no(self): + def sequence_no(self) -> int: + """ + Gets the sequence_no passed into the init. + + :rtype: int + """ return self._sequence_no @property - def n_requests(self): + def n_requests(self) -> int: + """ + Gets the n_requests passed into the init. + + :rtype: int + """ return self._n_requests @@ -142,7 +205,18 @@ class _HostDataReadAck(object): "_region_id", "_space_read"] - def __init__(self, channel, region_id, space_read): + def __init__(self, channel: Union[List[int], int], + region_id: Union[List[int], int], + space_read: Union[List[int], int]): + """ + + :param channel: + :type channel: list(int) or int + :param region_id: + :type region_id: list(int) or int + :param space_read: + :type space_read: list(int) or int + """ if not isinstance(channel, list): self._channel = [channel] else: @@ -158,7 +232,15 @@ def __init__(self, channel, region_id, space_read): else: self._space_read = space_read - def channel(self, ack_id): + def channel(self, ack_id: int) -> int: + """ + Gets the channel value for this ack_id. + + :param int ack_id: + :rtype: int + :raises SpinnmanInvalidParameterTypeException: + If the ack_id is invalid + """ if len(self._channel) > ack_id: return self._channel[ack_id] raise SpinnmanInvalidParameterTypeException( @@ -166,7 +248,15 @@ def channel(self, ack_id): "comprised between 0 and {0:d}; current value: {1:d}".format( len(self._channel) - 1, ack_id)) - def region_id(self, ack_id): + def region_id(self, ack_id: int) -> int: + """ + Gets the region_id value for this ack_id. + + :param int ack_id: + :rtype: int + :raises SpinnmanInvalidParameterTypeException: + If the ack_id is invalid + """ if len(self._region_id) > ack_id: return self._region_id[ack_id] raise SpinnmanInvalidParameterTypeException( @@ -174,7 +264,15 @@ def region_id(self, ack_id): "comprised between 0 and {0:d}; current value: {1:d}".format( len(self._region_id) - 1, ack_id)) - def space_read(self, ack_id): + def space_read(self, ack_id: int) -> int: + """ + Gets the space_read value for this ack_id. + + :param int ack_id: + :rtype: int + :raises SpinnmanInvalidParameterTypeException: + If the ack_id is invalid + """ if len(self._space_read) > ack_id: return self._space_read[ack_id] raise SpinnmanInvalidParameterTypeException( diff --git a/spinnman/messages/eieio/command_messages/spinnaker_request_read_data.py b/spinnman/messages/eieio/command_messages/spinnaker_request_read_data.py index 50d4e76e4..53f0e02df 100644 --- a/spinnman/messages/eieio/command_messages/spinnaker_request_read_data.py +++ b/spinnman/messages/eieio/command_messages/spinnaker_request_read_data.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from typing import List, Union import struct from spinn_utilities.overrides import overrides from spinnman.exceptions import ( @@ -37,8 +38,27 @@ class SpinnakerRequestReadData(EIEIOCommandMessage): "_header", "_requests") - def __init__(self, x, y, p, region_id, sequence_no, n_requests, - channel, start_address, space_to_be_read): + def __init__( + self, x: int, y: int, p: int, region_id: Union[List[int], int], + sequence_no: int, n_requests: int, channel: Union[List[int], int], + start_address: Union[List[int], int], + space_to_be_read: Union[List[int], int]): + """ + + :param int x: + :param int y: + :param int p: + :param region_id: + :type region_id: list(int) or int + :param int sequence_no: + :param int n_requests: + :param channel: + :type channel: list(int) or int + :param start_address: + :type start_address:: list(int) or int + :param space_to_be_read: + :type space_to_be_read: list(int) or int + """ # pylint: disable=too-many-arguments if not isinstance(channel, list): channel = [channel] @@ -73,35 +93,88 @@ def __init__(self, x, y, p, region_id, sequence_no, n_requests, channel, region_id, start_address, space_to_be_read) @property - def x(self): + def x(self) -> int: + """ + The x value passed into the init. + + :rtype: int + """ return self._header.x @property - def y(self): + def y(self) -> int: + """ + The y value passed into the init. + + :rtype: int + """ return self._header.y @property - def p(self): + def p(self) -> int: + """ + The p value passed into the init. + + :rtype: int + """ return self._header.p @property - def n_requests(self): + def n_requests(self) -> int: + """ + The n_requests value passed into the init. + + :rtype: int + """ return self._header.n_requests @property - def sequence_no(self): + def sequence_no(self) -> int: + """ + The sequence_no value passed into the init. + + :rtype: int + """ return self._header.sequence_no - def channel(self, request_id): + def channel(self, request_id: int) -> int: + """ + The channel for this request_id. + + :param int request_id: + :rtype: int + :raises IndexError: If the request_id is invalid + """ return self._requests.channel(request_id) - def region_id(self, request_id): + def region_id(self, request_id) -> int: + """ + The region_id for this request_id. + + :param int request_id: + :rtype: int + :raises IndexError: If the request_id is invalid + """ return self._requests.region_id(request_id) - def start_address(self, request_id): + def start_address(self, request_id) -> int: + """ + The start_address for this request_id. + + :param int request_id: + :rtype: int + :raises IndexError: If the request_id is invalid + """ return self._requests.start_address(request_id) - def space_to_be_read(self, request_id): + def space_to_be_read(self, request_id) -> int: + """ + The space_to_be_read for this request_id. + + :param int request_id: + :rtype: int + :raises IndexError: If the request_id is invalid + """ return self._requests.space_to_be_read(request_id) @staticmethod @@ -173,7 +246,16 @@ class _SpinnakerRequestReadDataHeader(object): "_sequence_no", "_p", "_x", "_y"] - def __init__(self, x, y, p, n_requests, sequence_no): + def __init__( + self, x: int, y: int, p: int, n_requests: int, sequence_no: int): + """ + + :param int x: + :param int y: + :param int p: + :param int n_requests: + :param int sequence_no: + """ # pylint: disable=too-many-arguments self._x = x self._y = y @@ -182,23 +264,48 @@ def __init__(self, x, y, p, n_requests, sequence_no): self._sequence_no = sequence_no @property - def x(self): + def x(self) -> int: + """ + The x value passed into the init. + + :rtype: int + """ return self._x @property - def y(self): + def y(self) -> int: + """ + The y value passed into the init. + + :rtype: int + """ return self._y @property - def p(self): + def p(self) -> int: + """ + The p value passed into the init. + + :rtype: int + """ return self._p @property - def sequence_no(self): + def sequence_no(self) -> int: + """ + The sequence_no value passed into the init. + + :rtype: int + """ return self._sequence_no @property - def n_requests(self): + def n_requests(self) -> int: + """ + The n_request value passed into the init. + + :rtype: int + """ return self._n_requests @@ -212,7 +319,21 @@ class _SpinnakerRequestReadDataRequest(object): "_start_address", "_space_to_be_read"] - def __init__(self, channel, region_id, start_address, space_to_be_read): + def __init__(self, channel: Union[List[int], int], + region_id: Union[List[int], int], + start_address: Union[List[int], int], + space_to_be_read: Union[List[int], int]): + """ + + :param channel: + :type channel: list(int) or int + :param region_id: + :type region_id: list(int) or int + :param start_address: + :type start_address: list(int) or int + :param space_to_be_read: + :type space_to_be_read: list(int) or int + """ if not isinstance(channel, list): self._channel = [channel] else: @@ -233,7 +354,16 @@ def __init__(self, channel, region_id, start_address, space_to_be_read): else: self._space_to_be_read = space_to_be_read - def channel(self, request_id): + def channel(self, request_id) -> int: + """ + Gets the channel for this request_id + + :param int request_id: + :rtype: int + :raises SpinnmanInvalidParameterTypeException: + if the request_id os too high + """ + if len(self._channel) > request_id: return self._channel[request_id] raise SpinnmanInvalidParameterTypeException( @@ -241,7 +371,15 @@ def channel(self, request_id): "comprised between 0 and {0:d}; current value: {1:d}".format( len(self._channel) - 1, request_id)) - def region_id(self, request_id): + def region_id(self, request_id) -> int: + """ + Gets the region_id for this request_id + + :param int request_id: + :rtype: int + :raises SpinnmanInvalidParameterTypeException: + if the request_id os too high + """ if len(self._region_id) > request_id: return self._region_id[request_id] raise SpinnmanInvalidParameterTypeException( @@ -249,7 +387,15 @@ def region_id(self, request_id): "comprised between 0 and {0:d}; current value: {1:d}".format( len(self._region_id) - 1, request_id)) - def start_address(self, request_id): + def start_address(self, request_id: int) -> int: + """ + Gets the start address for this request_id + + :param int request_id: + :rtype: int + :raises SpinnmanInvalidParameterTypeException: + if the request_id os too high + """ if len(self._start_address) > request_id: return self._start_address[request_id] raise SpinnmanInvalidParameterTypeException( @@ -257,7 +403,14 @@ def start_address(self, request_id): "comprised between 0 and {0:d}; current value: {1:d}".format( len(self._start_address) - 1, request_id)) - def space_to_be_read(self, request_id): + def space_to_be_read(self, request_id: int) -> int: + """ + Checks if there is enough space to request this id + + :rtype: bool + :raises SpinnmanInvalidParameterTypeException: + if the request_id os too high + """ if len(self._space_to_be_read) > request_id: return self._space_to_be_read[request_id] raise SpinnmanInvalidParameterTypeException( From 2de29694a409263677e57ba2630604d5cb517cef Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 30 Jan 2024 07:37:49 +0000 Subject: [PATCH 28/59] add overrides --- .../messages/eieio/command_messages/host_data_read.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/spinnman/messages/eieio/command_messages/host_data_read.py b/spinnman/messages/eieio/command_messages/host_data_read.py index 770d4f922..14e5268a6 100644 --- a/spinnman/messages/eieio/command_messages/host_data_read.py +++ b/spinnman/messages/eieio/command_messages/host_data_read.py @@ -14,6 +14,7 @@ import struct from typing import List, Union +from spinn_utilities.overrides import overrides from spinnman.exceptions import ( SpinnmanInvalidPacketException, SpinnmanInvalidParameterTypeException) from .eieio_command_message import EIEIOCommandMessage @@ -125,11 +126,14 @@ def space_read(self, ack_id: int) -> int: return self._acks.space_read(ack_id) @staticmethod - def get_min_packet_length(): + @overrides(EIEIOCommandMessage.get_min_packet_length) + def get_min_packet_length() -> int: return 8 @staticmethod - def from_bytestring(command_header, data, offset): + @overrides(EIEIOCommandMessage.from_bytestring) + def from_bytestring(command_header: EIEIOCommandHeader, data: bytes, + offset: int) -> "HostDataRead": n_requests, sequence_no = _PATTERN_BB.unpack_from(data, offset) offset += 2 @@ -149,7 +153,8 @@ def from_bytestring(command_header, data, offset): n_requests, sequence_no, channel, region_id, space_read) @property - def bytestring(self): + @overrides(EIEIOCommandMessage.bytestring) + def bytestring(self) -> bytes: byte_string = super().bytestring n_requests = self.n_requests byte_string += _PATTERN_BB.pack(n_requests, self.sequence_no) From e12a47ceb8eaaa5be46b4fcaf043cb1535e53397 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 30 Jan 2024 15:11:04 +0000 Subject: [PATCH 29/59] docs and typing --- spinnman/board_test_configuration.py | 21 ++++++++++++++- .../eieio_connection.py | 6 +++++ .../ip_address_connection.py | 10 ++++++- .../scamp_connection.py | 18 +++++++++++++ .../udp_packet_connections/udp_connection.py | 3 ++- .../abstract_multi_connection_process.py | 13 ++++++++++ spinnman/processes/application_run_process.py | 7 +++++ spinnman/processes/read_iobuf_process.py | 12 +++++++++ spinnman/spalloc/spalloc_client.py | 26 ++++++++++++++++++- spinnman/spalloc/spalloc_eieio_connection.py | 8 ++++++ 10 files changed, 120 insertions(+), 4 deletions(-) diff --git a/spinnman/board_test_configuration.py b/spinnman/board_test_configuration.py index 0c5c46604..882020cda 100644 --- a/spinnman/board_test_configuration.py +++ b/spinnman/board_test_configuration.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from typing import Optional import unittest from spinn_utilities.config_holder import set_config from spinn_utilities.ping import Ping @@ -24,7 +25,25 @@ def __init__(self): self.remotehost = None self.auto_detect_bmp = None - def set_up_remote_board(self, version=None): + def set_up_remote_board(self, version: Optional[int] = None): + """ + Gets a remote board to test, returning the first that it finds. + + Search order is + - Local 4 Chip board + - 48 Chip board "spinn-4.cs.man.ac.uk" + - Local 48 Chip board if at 192.168.240.1 + - Virtual machine + + The first three ignore the version param the last needs it + + Sets the version field in the configs. + + :param version: Version for a virtual if no physical board found + :type version: into or None + :raises unittest.SkipTest: + If no physical machine found and no version provided + """ if Ping.host_is_reachable("192.168.240.253"): self.remotehost = "192.168.240.253" set_config("Machine", "version", 3) diff --git a/spinnman/connections/udp_packet_connections/eieio_connection.py b/spinnman/connections/udp_packet_connections/eieio_connection.py index 3d9b403b7..19206f08c 100644 --- a/spinnman/connections/udp_packet_connections/eieio_connection.py +++ b/spinnman/connections/udp_packet_connections/eieio_connection.py @@ -72,6 +72,12 @@ def send_eieio_message(self, eieio_message: AbstractEIEIOMessage): def send_eieio_message_to( self, eieio_message: AbstractEIEIOMessage, ip_address: str, port: int): + """ + + :param AbstractEIEIOMessage eieio_message: + :param str ip_address: + :param int port: + """ self.send_to(eieio_message.bytestring, (ip_address, port)) @overrides(Listenable.get_receive_method) diff --git a/spinnman/connections/udp_packet_connections/ip_address_connection.py b/spinnman/connections/udp_packet_connections/ip_address_connection.py index ca4c80cf6..4c6e19fef 100644 --- a/spinnman/connections/udp_packet_connections/ip_address_connection.py +++ b/spinnman/connections/udp_packet_connections/ip_address_connection.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. from contextlib import suppress +from typing import Optional, Tuple from spinnman.constants import UDP_BOOT_CONNECTION_DEFAULT_PORT from .udp_connection import UDPConnection @@ -29,7 +30,14 @@ def __init__(self, local_host=None, local_port=UDP_BOOT_CONNECTION_DEFAULT_PORT): super().__init__(local_host=local_host, local_port=local_port) - def receive_ip_address(self, timeout=None): + def receive_ip_address(self, timeout: Optional[float] = None + ) -> Optional[Tuple[bytes, Tuple[str, int]]]: + """ + + :param timeout: + :type timeout: float or None + :rtype: tuple(byte, tuple(str, int)) or None + """ with suppress(Exception): (_, (ip_address, port)) = self.receive_with_address(timeout) if port == _BOOTROM_SPINN_PORT: diff --git a/spinnman/connections/udp_packet_connections/scamp_connection.py b/spinnman/connections/udp_packet_connections/scamp_connection.py index d0ae65973..9ae9f70bf 100644 --- a/spinnman/connections/udp_packet_connections/scamp_connection.py +++ b/spinnman/connections/udp_packet_connections/scamp_connection.py @@ -69,6 +69,12 @@ def chip_y(self) -> int: return self._chip_y def update_chip_coordinates(self, x: int, y: int): + """ + Sets the coordinates without checking they are valid. + + :param int x: + :param int y: + """ self._chip_x = x self._chip_y = y @@ -99,6 +105,11 @@ def receive_scp_response(self, timeout: Optional[float] = 1.0) -> Tuple[ def receive_scp_response_with_address( self, timeout: float = 1.0) -> Tuple[ SCPResult, int, bytes, int, str, int]: + """ + + :param float timeout: + :rtype: tuple(SCPResult, int, bytes, int, str, int) + """ data, (addr, port) = self.receive_with_address(timeout) result, sequence = _TWO_SHORTS.unpack_from(data, 10) return SCPResult(result), sequence, data, 2, addr, port @@ -110,6 +121,13 @@ def send_scp_request(self, scp_request: AbstractSCPRequest): def send_scp_request_to( self, scp_request: AbstractSCPRequest, x: int, y: int, ip_address: str): + """ + + :param AbstractSCPRequest scp_request: + :param int x: + :param int y: + :param str ip_address: + """ self.send_to( self.get_scp_data(scp_request, x, y), (str(ip_address), SCP_SCAMP_PORT)) diff --git a/spinnman/connections/udp_packet_connections/udp_connection.py b/spinnman/connections/udp_packet_connections/udp_connection.py index 92d10f8c1..b4ae01e98 100644 --- a/spinnman/connections/udp_packet_connections/udp_connection.py +++ b/spinnman/connections/udp_packet_connections/udp_connection.py @@ -200,7 +200,8 @@ def receive(self, timeout: Optional[float] = None) -> bytes: raise SpinnmanEOFException() return receive_message(self._socket, timeout, _MSG_MAX) - def receive_with_address(self, timeout=None): + def receive_with_address(self, timeout: Optional[float] = None) -> Tuple[ + bytes, Tuple[str, int]]: """ Receive data from the connection along with the address where the data was received from. diff --git a/spinnman/processes/abstract_multi_connection_process.py b/spinnman/processes/abstract_multi_connection_process.py index 6c8715049..e950f83d0 100644 --- a/spinnman/processes/abstract_multi_connection_process.py +++ b/spinnman/processes/abstract_multi_connection_process.py @@ -119,6 +119,11 @@ def _receive_error( self._connections.append(connection) def is_error(self) -> bool: + """ + Checks if any errors have been cached. + + :rtype: bool + """ return bool(self._exceptions) def _finish(self) -> None: @@ -162,6 +167,14 @@ def connection_selector(self) -> ConnectionSelector: return self._conn_selector def check_for_error(self, print_exception: bool = False): + """ + Check if any errors have been cached and raises them + + if print_exception it also logs the error. + + :param bool print_exception: + :raises SpinnmanGenericProcessException: If any was found + """ if len(self._exceptions) == 1: exc_info = sys.exc_info() sdp_header = self._error_requests[0].sdp_header diff --git a/spinnman/processes/application_run_process.py b/spinnman/processes/application_run_process.py index 9f19e0534..4b069dcb7 100644 --- a/spinnman/processes/application_run_process.py +++ b/spinnman/processes/application_run_process.py @@ -21,6 +21,13 @@ class ApplicationRunProcess(AbstractMultiConnectionProcess[CheckOKResponse]): __slots__ = () def run(self, app_id: int, core_subsets: CoreSubsets, wait: bool): + """ + Runs the application. + + :param int app_id: + :param CoreSubsets core_subsets: + :param bool wait: +` """ with self._collect_responses(): for core_subset in core_subsets: self._send_request(ApplicationRun( diff --git a/spinnman/processes/read_iobuf_process.py b/spinnman/processes/read_iobuf_process.py index a6d44c644..510c3d836 100644 --- a/spinnman/processes/read_iobuf_process.py +++ b/spinnman/processes/read_iobuf_process.py @@ -47,11 +47,23 @@ class _NextRegion: first_read_size: int def next_at(self, address: int) -> '_NextRegion': + """ + + :param int address: + :rtype: _NextRegion + """ return _NextRegion( self.scamp_coords, self.core_coords, self.n + 1, address, self.first_read_size) def tail(self, address: int, size: int, offset: int) -> _RegionTail: + """ + + :param int address: + :param int size: + :param int offset: + :rtype: _RegionTail + """ return _RegionTail( self.scamp_coords, self.core_coords, self.n, address, size, offset) diff --git a/spinnman/spalloc/spalloc_client.py b/spinnman/spalloc/spalloc_client.py index 320eb9f89..de3391a42 100644 --- a/spinnman/spalloc/spalloc_client.py +++ b/spinnman/spalloc/spalloc_client.py @@ -68,7 +68,13 @@ _msg_to = struct.Struct(" str: + """ + Makes sure the url is the correct format. + + :param str url: original url + :rtype: str + """ parts = urlparse(url) if parts.scheme != 'https': parts = ParseResult("https", parts.netloc, parts.path, @@ -887,10 +893,19 @@ def _open_connection(self) -> int: @overrides(Connection.is_connected) def is_connected(self) -> bool: + """ + Determines if the medium is connected at this point in time. + + :return: True if the medium is connected, False otherwise + :rtype: bool + """ return self._connected @overrides(Connection.close) def close(self) -> None: + """ + Closes the connection. + """ self._close() @overrides(SpallocProxiedConnection.send) @@ -942,10 +957,19 @@ def _port(self) -> Optional[int]: @overrides(Connection.is_connected) def is_connected(self) -> bool: + """ + Determines if the medium is connected at this point in time. + + :return: True if the medium is connected, False otherwise + :rtype: bool + """ return self._connected @overrides(Connection.close) def close(self) -> None: + """ + Closes the connection. + """ self._close() @overrides(SpallocProxiedConnection.send) diff --git a/spinnman/spalloc/spalloc_eieio_connection.py b/spinnman/spalloc/spalloc_eieio_connection.py index 1a8c1c6b9..6cfbb063a 100644 --- a/spinnman/spalloc/spalloc_eieio_connection.py +++ b/spinnman/spalloc/spalloc_eieio_connection.py @@ -51,6 +51,14 @@ def send_eieio_message(self, eieio_message: AbstractEIEIOMessage): def send_eieio_message_to_core( self, eieio_message: AbstractEIEIOMessage, x: int, y: int, p: int): + """ + + :param AbstractEIEIOMessage eieio_message: + :param int x: + :param int y: + :param int p: + :rtype: None + """ sdp_message = SDPMessage( SDPHeader( flags=SDPFlag.REPLY_NOT_EXPECTED, tag=0, From 92065fa9efd445e9506ee202f963dd85ff07f531 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 30 Jan 2024 15:48:45 +0000 Subject: [PATCH 30/59] docs --- pylint.bash | 3 ++- spinnman/board_test_configuration.py | 3 +++ spinnman/extended/version3transceiver.py | 3 +++ spinnman/extended/version5transceiver.py | 3 +++ .../eieio/data_messages/eieio_data_header.py | 3 +++ spinnman/processes/application_run_process.py | 3 +++ spinnman/processes/get_cpu_info_process.py | 5 +++++ spinnman/processes/get_exclude_cpu_info_process.py | 13 +++++++++++++ spinnman/processes/get_heap_process.py | 4 ++++ spinnman/processes/get_include_cpu_info_process.py | 7 +++++++ spinnman/processes/get_n_cores_in_state_process.py | 3 +++ spinnman/processes/get_tags_process.py | 3 +++ 12 files changed, 52 insertions(+), 1 deletion(-) diff --git a/pylint.bash b/pylint.bash index 065f0ae89..71f46ccc6 100644 --- a/pylint.bash +++ b/pylint.bash @@ -28,5 +28,6 @@ cat "../SupportScripts/actions/pylint/default_dict.txt" >$dict cat ".pylint_dict.txt" >>$dict # pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error spinnman -pylint --enable=missing-function-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman +# check docs +pylint --enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman diff --git a/spinnman/board_test_configuration.py b/spinnman/board_test_configuration.py index 882020cda..416c75df4 100644 --- a/spinnman/board_test_configuration.py +++ b/spinnman/board_test_configuration.py @@ -20,6 +20,9 @@ class BoardTestConfiguration(object): + """ + Configuration to use for a test board + """ def __init__(self): self.remotehost = None diff --git a/spinnman/extended/version3transceiver.py b/spinnman/extended/version3transceiver.py index c2b8e6603..524d2209e 100644 --- a/spinnman/extended/version3transceiver.py +++ b/spinnman/extended/version3transceiver.py @@ -16,4 +16,7 @@ class ExtendedVersion3Transceiver(Version3Transceiver, ExtendedTransceiver): + """ + A Transceiver specific for a 4 chip (spin 1) with the extended methods. + """ pass diff --git a/spinnman/extended/version5transceiver.py b/spinnman/extended/version5transceiver.py index 24e1a7718..831a3d3b4 100644 --- a/spinnman/extended/version5transceiver.py +++ b/spinnman/extended/version5transceiver.py @@ -16,4 +16,7 @@ class ExtendedVersion5Transceiver(Version5Transceiver, ExtendedTransceiver): + """ + A Transceiver specific for a 48 chip (spin 1) with the extended methods. + """ pass diff --git a/spinnman/messages/eieio/data_messages/eieio_data_header.py b/spinnman/messages/eieio/data_messages/eieio_data_header.py index 3af498bbf..0e94340e7 100644 --- a/spinnman/messages/eieio/data_messages/eieio_data_header.py +++ b/spinnman/messages/eieio/data_messages/eieio_data_header.py @@ -30,6 +30,9 @@ class EIEIODataHeader(object): + """ + The header part of EIEIO data. + """ __slots__ = ( "_count", "_eieio_type", diff --git a/spinnman/processes/application_run_process.py b/spinnman/processes/application_run_process.py index 4b069dcb7..db7292cd6 100644 --- a/spinnman/processes/application_run_process.py +++ b/spinnman/processes/application_run_process.py @@ -18,6 +18,9 @@ class ApplicationRunProcess(AbstractMultiConnectionProcess[CheckOKResponse]): + """ + A process to run an application. + """ __slots__ = () def run(self, app_id: int, core_subsets: CoreSubsets, wait: bool): diff --git a/spinnman/processes/get_cpu_info_process.py b/spinnman/processes/get_cpu_info_process.py index 20e19b2e6..c825c6392 100644 --- a/spinnman/processes/get_cpu_info_process.py +++ b/spinnman/processes/get_cpu_info_process.py @@ -26,6 +26,11 @@ class GetCPUInfoProcess(AbstractMultiConnectionProcess[Response]): + """ + Gets the CPU for processors over the provided connection. + + This base class returns info for all states. + """ __slots__ = ("__cpu_infos", ) def __init__(self, connection_selector: ConnectionSelector): diff --git a/spinnman/processes/get_exclude_cpu_info_process.py b/spinnman/processes/get_exclude_cpu_info_process.py index ca5bca04e..e0d63f96f 100644 --- a/spinnman/processes/get_exclude_cpu_info_process.py +++ b/spinnman/processes/get_exclude_cpu_info_process.py @@ -22,10 +22,23 @@ class GetExcludeCPUInfoProcess(GetCPUInfoProcess): + """ + Gets the CPU for processors over the provided connection. + + This class returns all but infos for the requested states. + """ + __slots__ = ("__states", ) def __init__(self, connection_selector: ConnectionSelector, states: Container[CPUState]): + """ + :param connection_selector: + :type connection_selector: + AbstractMultiConnectionProcessConnectionSelector + :param iterable(CPUState) states: + The states for which info is NOT required. + """ super().__init__(connection_selector) self.__states = states diff --git a/spinnman/processes/get_heap_process.py b/spinnman/processes/get_heap_process.py index dc4c43f50..c9cd7663c 100644 --- a/spinnman/processes/get_heap_process.py +++ b/spinnman/processes/get_heap_process.py @@ -32,6 +32,10 @@ class GetHeapProcess(AbstractMultiConnectionProcess[Response]): + """ + Gets Heap information using the provided connector. + + """ __slots__ = ( "_blocks", "_heap_address", diff --git a/spinnman/processes/get_include_cpu_info_process.py b/spinnman/processes/get_include_cpu_info_process.py index 749549983..84069c995 100644 --- a/spinnman/processes/get_include_cpu_info_process.py +++ b/spinnman/processes/get_include_cpu_info_process.py @@ -22,6 +22,11 @@ class GetIncludeCPUInfoProcess(GetCPUInfoProcess): + """ + Gets the CPU for processors over the provided connection. + + This class returns only infos for the requested states. + """ __slots__ = ("__states", ) def __init__(self, connection_selector: ConnectionSelector, @@ -30,6 +35,8 @@ def __init__(self, connection_selector: ConnectionSelector, :param connection_selector: :type connection_selector: AbstractMultiConnectionProcessConnectionSelector + :param iterable(CPUState) states: + The states for which info is required. """ super().__init__(connection_selector) self.__states = states diff --git a/spinnman/processes/get_n_cores_in_state_process.py b/spinnman/processes/get_n_cores_in_state_process.py index d557c661c..deeaade4e 100644 --- a/spinnman/processes/get_n_cores_in_state_process.py +++ b/spinnman/processes/get_n_cores_in_state_process.py @@ -21,6 +21,9 @@ class GetNCoresInStateProcess(AbstractMultiConnectionProcess): + """ + Gets the state of a core over the provided connection. + """ __slots__ = [ "_n_cores"] diff --git a/spinnman/processes/get_tags_process.py b/spinnman/processes/get_tags_process.py index 16671f33f..bba24d005 100644 --- a/spinnman/processes/get_tags_process.py +++ b/spinnman/processes/get_tags_process.py @@ -26,6 +26,9 @@ class GetTagsProcess(AbstractMultiConnectionProcess): + """ + Gets information about the tags over the provided connection. + """ __slots__ = ( "_tags", "_tag_info") From 1e799fa31daae04c13b1a67cb48e0b6d4a464a7d Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 31 Jan 2024 08:30:52 +0000 Subject: [PATCH 31/59] use f strings --- pylint.bash | 6 +++- .../ip_address_connection.py | 4 +-- spinnman/exceptions.py | 31 +++++++--------- .../eieio/command_messages/host_data_read.py | 18 +++++----- .../spinnaker_request_read_data.py | 35 ++++++++++--------- .../eieio/data_messages/eieio_data_header.py | 10 +++--- .../eieio/data_messages/eieio_data_message.py | 15 ++++---- spinnman/model/cpu_info.py | 6 ++-- spinnman/model/heap_element.py | 7 ++-- spinnman/model/version_info.py | 6 ++-- spinnman/spalloc/session.py | 2 ++ 11 files changed, 69 insertions(+), 71 deletions(-) diff --git a/pylint.bash b/pylint.bash index 71f46ccc6..1e3241844 100644 --- a/pylint.bash +++ b/pylint.bash @@ -28,6 +28,10 @@ cat "../SupportScripts/actions/pylint/default_dict.txt" >$dict cat ".pylint_dict.txt" >>$dict # pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error spinnman + +# one test +pylint --enable=consider-using-f-string --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman + # check docs -pylint --enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman +# pylint --enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman diff --git a/spinnman/connections/udp_packet_connections/ip_address_connection.py b/spinnman/connections/udp_packet_connections/ip_address_connection.py index 4c6e19fef..10788ac67 100644 --- a/spinnman/connections/udp_packet_connections/ip_address_connection.py +++ b/spinnman/connections/udp_packet_connections/ip_address_connection.py @@ -45,5 +45,5 @@ def receive_ip_address(self, timeout: Optional[float] = None return None def __repr__(self): - return "IPAddressesConnection(local_host={}, local_port={})".format( - self.local_ip_address, self.local_port) + return f"IPAddressesConnection(local_host={self.local_ip_address}," \ + f" local_port={self.local_port})" diff --git a/spinnman/exceptions.py b/spinnman/exceptions.py index 95f5fa250..c8bf2ed61 100644 --- a/spinnman/exceptions.py +++ b/spinnman/exceptions.py @@ -283,19 +283,16 @@ def __init__(self, error_requests: List[AbstractSCPRequest], error_requests, exceptions, tracebacks, connections): sdp_header = error_request.sdp_header phys_p = sdp_header.get_physical_cpu_id() - location = "board {} with ethernet chip {}:{} [{}:{}:{}{}]".format( - connection.remote_ip_address, connection.chip_x, - connection.chip_y, sdp_header.destination_chip_x, - sdp_header.destination_chip_y, - sdp_header.destination_cpu, phys_p) + location = f"board {connection.remote_ip_address} with ethernet " \ + f"chip {connection.chip_x}:{connection.chip_y} " \ + f"[{sdp_header.destination_chip_x}:" \ + f"{sdp_header.destination_chip_y,}:" \ + f"{sdp_header.destination_cpu}{phys_p}]" problem += \ - " Received exception class: {}\n" \ - " With message {}\n" \ - " When sending to {}\n" \ - " Stack trace: {}\n".format( - exception.__class__.__name__, str(exception), - location, - traceback.format_tb(trace_back)) + f" Received exception class: {exception.__class__.__name__}\n" \ + f" With message {str(exception)}\n" \ + f" When sending to {location}\n" \ + f" Stack trace: {traceback.format_tb(trace_back)}\n" super().__init__(problem) @@ -317,12 +314,10 @@ def __init__( """ # pylint: disable=too-many-arguments super().__init__( - " Received exception class: {} \n" - " With message: {} \n" - " When sending to {}:{}:{}{}\n" - " Stack trace: {}\n".format( - exception.__class__.__name__, str(exception), x, y, p, - phys_p, traceback.format_tb(tb))) + f" Received exception class: {exception.__class__.__name__} \n" + f" With message: {str(exception)} \n" + f" When sending to {x}:{y}:{p}{phys_p}\n" + f" Stack trace: {traceback.format_tb(tb)}\n") self._stored_exception = exception if tb2 is not None: diff --git a/spinnman/messages/eieio/command_messages/host_data_read.py b/spinnman/messages/eieio/command_messages/host_data_read.py index 14e5268a6..e32eef7c8 100644 --- a/spinnman/messages/eieio/command_messages/host_data_read.py +++ b/spinnman/messages/eieio/command_messages/host_data_read.py @@ -249,9 +249,9 @@ def channel(self, ack_id: int) -> int: if len(self._channel) > ack_id: return self._channel[ack_id] raise SpinnmanInvalidParameterTypeException( - "request_id", "integer", "channel ack_id needs to be" - "comprised between 0 and {0:d}; current value: {1:d}".format( - len(self._channel) - 1, ack_id)) + "request_id", "integer", + f"channel ack_id needs to be comprised between 0 and " + f"{len(self._channel) - 1:d}; current value: {ack_id:d}") def region_id(self, ack_id: int) -> int: """ @@ -265,9 +265,9 @@ def region_id(self, ack_id: int) -> int: if len(self._region_id) > ack_id: return self._region_id[ack_id] raise SpinnmanInvalidParameterTypeException( - "request_id", "integer", "region ID ack_id needs to be" - "comprised between 0 and {0:d}; current value: {1:d}".format( - len(self._region_id) - 1, ack_id)) + "request_id", "integer", + f"region ID ack_id needs to be comprised between 0 and " + f"{len(self._region_id) - 1:d}; current value: {ack_id:d}") def space_read(self, ack_id: int) -> int: """ @@ -281,6 +281,6 @@ def space_read(self, ack_id: int) -> int: if len(self._space_read) > ack_id: return self._space_read[ack_id] raise SpinnmanInvalidParameterTypeException( - "request_id", "integer", "start address ack_id needs to be" - "comprised between 0 and {0:d}; current value: {1:d}".format( - len(self._space_read) - 1, ack_id)) + "request_id", "integer", + f"start address ack_id needs to be comprised between 0 and " + f"{len(self._space_read) - 1:d}; current value: {ack_id:d}") diff --git a/spinnman/messages/eieio/command_messages/spinnaker_request_read_data.py b/spinnman/messages/eieio/command_messages/spinnaker_request_read_data.py index 53f0e02df..f2c64f800 100644 --- a/spinnman/messages/eieio/command_messages/spinnaker_request_read_data.py +++ b/spinnman/messages/eieio/command_messages/spinnaker_request_read_data.py @@ -79,11 +79,11 @@ def __init__( raise SpinnmanInvalidPacketException( "SpinnakerRequestReadData", "The format for a SpinnakerRequestReadData packet is " - "invalid: {0:d} request(s), {1:d} start address(es) " - "defined, {2:d} space(s) to be read defined, {3:d} region(s) " - "defined, {4:d} channel(s) defined".format( - n_requests, len(start_address), len(space_to_be_read), - len(region_id), len(channel))) + f"invalid: {n_requests:d} request(s), " + f"{len(start_address):d} start address(es) defined, " + f"{len(space_to_be_read):d} space(s) to be read defined, " + f"{len(region_id):d} region(s) defined, " + f"{len(channel):d} channel(s) defined") super().__init__(EIEIOCommandHeader( EIEIO_COMMAND_IDS.SPINNAKER_REQUEST_READ_DATA)) @@ -367,9 +367,9 @@ def channel(self, request_id) -> int: if len(self._channel) > request_id: return self._channel[request_id] raise SpinnmanInvalidParameterTypeException( - "request_id", "integer", "channel request needs to be" - "comprised between 0 and {0:d}; current value: {1:d}".format( - len(self._channel) - 1, request_id)) + "request_id", "integer", + f"channel request needs to be comprised between 0 and " + f"{len(self._channel) - 1:d}; current value: {request_id:d}") def region_id(self, request_id) -> int: """ @@ -383,9 +383,9 @@ def region_id(self, request_id) -> int: if len(self._region_id) > request_id: return self._region_id[request_id] raise SpinnmanInvalidParameterTypeException( - "request_id", "integer", "region ID request needs to be" - "comprised between 0 and {0:d}; current value: {1:d}".format( - len(self._region_id) - 1, request_id)) + "request_id", "integer", + f"region ID request needs to be comprised between 0 and " + f"{len(self._region_id) - 1:d}; current value: {request_id:d}") def start_address(self, request_id: int) -> int: """ @@ -399,9 +399,9 @@ def start_address(self, request_id: int) -> int: if len(self._start_address) > request_id: return self._start_address[request_id] raise SpinnmanInvalidParameterTypeException( - "request_id", "integer", "start address request needs to be" - "comprised between 0 and {0:d}; current value: {1:d}".format( - len(self._start_address) - 1, request_id)) + "request_id", "integer", + f"start address request needs to be comprised between 0 and " + f"{len(self._start_address) - 1:d}; current value: {request_id:d}") def space_to_be_read(self, request_id: int) -> int: """ @@ -414,6 +414,7 @@ def space_to_be_read(self, request_id: int) -> int: if len(self._space_to_be_read) > request_id: return self._space_to_be_read[request_id] raise SpinnmanInvalidParameterTypeException( - "request_id", "integer", "space to be read request needs to be" - "comprised between 0 and {0:d}; current value: {1:d}".format( - len(self._space_to_be_read) - 1, request_id)) + "request_id", "integer", + f"space to be read request needs to be comprised between 0 and " + f"{len(self._space_to_be_read) - 1:d}; " + f"current value: {request_id:d}") diff --git a/spinnman/messages/eieio/data_messages/eieio_data_header.py b/spinnman/messages/eieio/data_messages/eieio_data_header.py index 0e94340e7..ecded471c 100644 --- a/spinnman/messages/eieio/data_messages/eieio_data_header.py +++ b/spinnman/messages/eieio/data_messages/eieio_data_header.py @@ -298,11 +298,11 @@ def from_bytestring(data: bytes, offset: int) -> 'EIEIODataHeader': is_time=bool(payload_is_timestamp), count=count) def __str__(self): - return ("EIEIODataHeader:prefix={}:prefix_type={}:payload_base={}:" - "is_time={}:type={}:tag={}:count={}".format( - self._prefix, self._prefix_type, self._payload_base, - self._is_time, self._eieio_type.value, self._tag, - self._count)) + return (f"EIEIODataHeader:prefix={self._prefix}:" + f"prefix_type={self._prefix_type}:" + f"payload_base={self._payload_base}:" + "is_time={self._is_time}:type={self._eieio_type.value}:" + "tag={self._tag}:count={self._count}") def __repr__(self): return self.__str__() diff --git a/spinnman/messages/eieio/data_messages/eieio_data_message.py b/spinnman/messages/eieio/data_messages/eieio_data_message.py index 306b83b12..9da649a33 100644 --- a/spinnman/messages/eieio/data_messages/eieio_data_message.py +++ b/spinnman/messages/eieio/data_messages/eieio_data_message.py @@ -170,14 +170,12 @@ def add_key_and_payload(self, key: int, payload: int): """ if key > self._header.eieio_type.max_value: raise SpinnmanInvalidParameterException( - "key", key, - "Larger than the maximum allowed of {}".format( - self._header.eieio_type.max_value)) + "key", key, "Larger than the maximum allowed of " + f"{self._header.eieio_type.max_value}") if payload > self._header.eieio_type.max_value: raise SpinnmanInvalidParameterException( - "payload", payload, - "Larger than the maximum allowed of {}".format( - self._header.eieio_type.max_value)) + "payload", payload, "Larger than the maximum allowed of " + f"{self._header.eieio_type.max_value}") self.add_element(KeyPayloadDataElement( key, payload, self._header.is_time)) @@ -193,9 +191,8 @@ def add_key(self, key: int): """ if key > self._header.eieio_type.max_value: raise SpinnmanInvalidParameterException( - "key", key, - "Larger than the maximum allowed of {}".format( - self._header.eieio_type.max_value)) + "key", key, "Larger than the maximum allowed of " + f"{self._header.eieio_type.max_value}") self.add_element(KeyDataElement(key)) def add_element(self, element: AbstractDataElement): diff --git a/spinnman/model/cpu_info.py b/spinnman/model/cpu_info.py index 2feeafd2e..f8ed2ee62 100644 --- a/spinnman/model/cpu_info.py +++ b/spinnman/model/cpu_info.py @@ -343,9 +343,9 @@ def software_version(self) -> int: return self.__software_version def __str__(self) -> str: - return "{}:{}:{:02n} ({:02n}) {:18} {:16s} {:3n}".format( - self.x, self.y, self.p, self.physical_cpu_id, self.__state.name, - self.__application_name, self.__application_id) + return (f"{self.x}:{self.y}:{self.p:02n} ({self.physical_cpu_id:02n}) " + f"{self.__state.name:18} {self.__application_name:16s} " + f"{self.__application_id:3n}") def get_status_string(self) -> str: """ diff --git a/spinnman/model/heap_element.py b/spinnman/model/heap_element.py index 80cdbf90b..aa41b7395 100644 --- a/spinnman/model/heap_element.py +++ b/spinnman/model/heap_element.py @@ -103,9 +103,8 @@ def app_id(self) -> Optional[int]: def __str__(self) -> str: if self._is_free: - return "FREE 0x{:8X} SIZE: {:9d}".format( - self._block_address, self.size) + return f"FREE 0x{self._block_address:8X} SIZE: {self.size:9d}" assert self._tag is not None assert self._app_id is not None - return "BLOCK 0x{:8X} SIZE: {:9d} TAG: {:3d} APP_ID: {:3d}".format( - self._block_address, self.size, self._tag, self._app_id) + return "BLOCK 0x{self._block_address:8X} SIZE: {self.size:9d} " \ + "TAG: {self._tag:3d} APP_ID: {self._app_id:3d}" diff --git a/spinnman/model/version_info.py b/spinnman/model/version_info.py index 67feb5195..e0f10ac1e 100644 --- a/spinnman/model/version_info.py +++ b/spinnman/model/version_info.py @@ -146,6 +146,6 @@ def version_string(self) -> str: return self._version_string def __str__(self) -> str: - return "[Version: {} {} at {}:{}:{}:{} (built {})]".format( - self._name, self._version_string, self._hardware, self._x, self._y, - self._p, asctime(localtime(self._build_date))) + return (f"[Version: {self._name} {self._version_string} at " + f"{self._hardware}:{self._x}:{self._y}:{self._p} " + f"(built {asctime(localtime(self._build_date))})]") diff --git a/spinnman/spalloc/session.py b/spinnman/spalloc/session.py index 6479f5ab5..cae67fdd6 100644 --- a/spinnman/spalloc/session.py +++ b/spinnman/spalloc/session.py @@ -37,6 +37,7 @@ def pp_req(request: requests.PreparedRequest): """ print(">>>>>>>>>>>START>>>>>>>>>>>\n") print(f"{request.method} {request.url}") + # pylint: disable=consider-using-f-string print('\r\n'.join('{}: {}'.format(*kv) for kv in request.headers.items())) if request.body: @@ -46,6 +47,7 @@ def pp_resp(response: requests.Response): """ :param ~requests.Response response: """ + # pylint: disable=consider-using-f-string print('{}\n{}\r\n{}\r\n\r\n{}'.format( '<<<<<<<<<< Date: Wed, 31 Jan 2024 08:36:27 +0000 Subject: [PATCH 32/59] dont use range(len --- spinnman/model/chip_info.py | 5 +---- spinnman/model/p2p_table.py | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/spinnman/model/chip_info.py b/spinnman/model/chip_info.py index dbd406e07..94a885245 100644 --- a/spinnman/model/chip_info.py +++ b/spinnman/model/chip_info.py @@ -61,10 +61,7 @@ def __init__(self, system_data: bytes, offset: int): "virtual_to_physical_core_map") self._virtual_core_ids: List[int] = list() - for physical_core_id in range( - 0, len(self._physical_to_virtual_core_map)): - virtual_core_id = self._physical_to_virtual_core_map[ - physical_core_id] + for virtual_core_id in self._physical_to_virtual_core_map: if virtual_core_id != 0xFF: self._virtual_core_ids.append(virtual_core_id) self._virtual_core_ids.sort() diff --git a/spinnman/model/p2p_table.py b/spinnman/model/p2p_table.py index 32ae021a7..e40c04f75 100644 --- a/spinnman/model/p2p_table.py +++ b/spinnman/model/p2p_table.py @@ -38,11 +38,10 @@ def __init__(self, width: int, height: int, self._routes: Dict[Tuple[int, int], P2PTableRoute] = dict() self._width = width self._height = height - for x in range(len(column_data)): + for x, (data, offset) in enumerate(column_data): y = 0 pos = 0 while y < height: - data, offset = column_data[x] next_word, = _ONE_WORD.unpack_from(data, offset + (pos * 4)) pos += 1 for entry in range(min(8, height - y)): From 4b85b109d63c0d0bd7cbc0f2c2ce236a46c00fed Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 31 Jan 2024 08:38:51 +0000 Subject: [PATCH 33/59] no pass needed if you have a comment --- spinnman/extended/version3transceiver.py | 2 +- spinnman/extended/version5transceiver.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/spinnman/extended/version3transceiver.py b/spinnman/extended/version3transceiver.py index 524d2209e..4c216e911 100644 --- a/spinnman/extended/version3transceiver.py +++ b/spinnman/extended/version3transceiver.py @@ -19,4 +19,4 @@ class ExtendedVersion3Transceiver(Version3Transceiver, ExtendedTransceiver): """ A Transceiver specific for a 4 chip (spin 1) with the extended methods. """ - pass + diff --git a/spinnman/extended/version5transceiver.py b/spinnman/extended/version5transceiver.py index 831a3d3b4..9d2514e0b 100644 --- a/spinnman/extended/version5transceiver.py +++ b/spinnman/extended/version5transceiver.py @@ -18,5 +18,4 @@ class ExtendedVersion5Transceiver(Version5Transceiver, ExtendedTransceiver): """ A Transceiver specific for a 48 chip (spin 1) with the extended methods. - """ - pass + """ \ No newline at end of file From f4ce1ecbc515fbf6434b360bf6ad3174f183af52 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 31 Jan 2024 10:10:20 +0000 Subject: [PATCH 34/59] fix import order --- pylint.bash | 2 +- .../udp_packet_connections/bmp_connection.py | 5 +++- .../udp_packet_connections/boot_connection.py | 4 ++- .../eieio_connection.py | 7 +++-- .../udp_packet_connections/sdp_connection.py | 4 ++- spinnman/extended/version3transceiver.py | 3 +- spinnman/extended/version5transceiver.py | 3 +- spinnman/get_cores_in_run_state.py | 7 +++-- .../eieio/command_messages/host_data_read.py | 4 ++- .../command_messages/host_data_read_ack.py | 2 +- .../host_send_sequenced_data.py | 6 ++-- .../notification_protocol_db_location.py | 2 +- .../notification_protocol_pause_stop.py | 2 +- .../notification_protocol_start_resume.py | 2 +- .../spinnaker_request_buffers.py | 2 +- .../spinnaker_request_read_data.py | 4 ++- .../eieio/command_messages/start_requests.py | 2 +- .../eieio/command_messages/stop_requests.py | 2 +- .../scp/abstract_messages/bmp_request.py | 6 +++- .../messages/scp/impl/fixed_route_init.py | 4 ++- spinnman/messages/scp/impl/iptag_get.py | 4 +-- spinnman/messages/sdp/sdp_header.py | 2 +- .../spinnaker_boot/spinnaker_boot_messages.py | 8 +++-- spinnman/model/chip_summary_info.py | 2 +- spinnman/model/cpu_infos.py | 4 +-- .../abstract_multi_connection_process.py | 11 +++++-- spinnman/processes/application_run_process.py | 2 +- .../processes/fixed_connection_selector.py | 5 ++-- spinnman/processes/get_machine_process.py | 10 +++++-- .../processes/get_n_cores_in_state_process.py | 2 +- spinnman/processes/get_routes_process.py | 6 ++-- spinnman/processes/get_tags_process.py | 5 +++- spinnman/processes/get_version_process.py | 5 +++- spinnman/processes/load_routes_process.py | 9 ++++-- .../read_fixed_route_routing_entry_process.py | 5 +++- spinnman/processes/read_memory_process.py | 5 +++- .../processes/send_single_command_process.py | 8 +++-- spinnman/spalloc/session.py | 8 +++-- spinnman/spalloc/spalloc_client.py | 30 ++++++++++--------- 39 files changed, 134 insertions(+), 70 deletions(-) diff --git a/pylint.bash b/pylint.bash index 1e3241844..6ed458cee 100644 --- a/pylint.bash +++ b/pylint.bash @@ -30,7 +30,7 @@ cat ".pylint_dict.txt" >>$dict # pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error spinnman # one test -pylint --enable=consider-using-f-string --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman +pylint --enable=wrong-import-order --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman # check docs # pylint --enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman diff --git a/spinnman/connections/udp_packet_connections/bmp_connection.py b/spinnman/connections/udp_packet_connections/bmp_connection.py index 584c4129c..b85a4c176 100644 --- a/spinnman/connections/udp_packet_connections/bmp_connection.py +++ b/spinnman/connections/udp_packet_connections/bmp_connection.py @@ -14,14 +14,17 @@ import struct from typing import Optional, Sequence, Tuple + from spinn_utilities.overrides import overrides -from .udp_connection import UDPConnection + from spinnman.constants import SCP_SCAMP_PORT from spinnman.messages.scp.enums import SCPResult from spinnman.messages.scp.abstract_messages import AbstractSCPRequest from spinnman.connections.abstract_classes import AbstractSCPConnection from spinnman.model import BMPConnectionData +from .udp_connection import UDPConnection + _TWO_SHORTS = struct.Struct("<2H") _TWO_SKIP = struct.Struct("<2x") diff --git a/spinnman/connections/udp_packet_connections/boot_connection.py b/spinnman/connections/udp_packet_connections/boot_connection.py index 7ab0d5fd4..f7c41536c 100644 --- a/spinnman/connections/udp_packet_connections/boot_connection.py +++ b/spinnman/connections/udp_packet_connections/boot_connection.py @@ -14,10 +14,12 @@ import time from typing import Optional -from .udp_connection import UDPConnection + from spinnman.messages.spinnaker_boot import SpinnakerBootMessage from spinnman.constants import UDP_BOOT_CONNECTION_DEFAULT_PORT +from .udp_connection import UDPConnection + _ANTI_FLOOD_DELAY = 0.1 diff --git a/spinnman/connections/udp_packet_connections/eieio_connection.py b/spinnman/connections/udp_packet_connections/eieio_connection.py index 19206f08c..c3b228b2e 100644 --- a/spinnman/connections/udp_packet_connections/eieio_connection.py +++ b/spinnman/connections/udp_packet_connections/eieio_connection.py @@ -14,13 +14,16 @@ import struct from typing import Callable, Optional -from .udp_connection import UDPConnection + +from spinn_utilities.overrides import overrides + from spinnman.connections.abstract_classes import Listenable from spinnman.messages.eieio import ( read_eieio_command_message, read_eieio_data_message) -from spinn_utilities.overrides import overrides from spinnman.messages.eieio import AbstractEIEIOMessage +from .udp_connection import UDPConnection + _ONE_SHORT = struct.Struct(" Date: Wed, 31 Jan 2024 10:11:44 +0000 Subject: [PATCH 35/59] spacing --- spinnman/extended/version3transceiver.py | 1 - spinnman/extended/version5transceiver.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/spinnman/extended/version3transceiver.py b/spinnman/extended/version3transceiver.py index 4601e52fb..872a7976a 100644 --- a/spinnman/extended/version3transceiver.py +++ b/spinnman/extended/version3transceiver.py @@ -20,4 +20,3 @@ class ExtendedVersion3Transceiver(Version3Transceiver, ExtendedTransceiver): """ A Transceiver specific for a 4 chip (spin 1) with the extended methods. """ - diff --git a/spinnman/extended/version5transceiver.py b/spinnman/extended/version5transceiver.py index fbc89b42a..a5969e51a 100644 --- a/spinnman/extended/version5transceiver.py +++ b/spinnman/extended/version5transceiver.py @@ -19,4 +19,4 @@ class ExtendedVersion5Transceiver(Version5Transceiver, ExtendedTransceiver): """ A Transceiver specific for a 48 chip (spin 1) with the extended methods. - """ \ No newline at end of file + """ From 4f1e1cf14bf66a36a8369367236d61f3d8e118f5 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 31 Jan 2024 10:12:18 +0000 Subject: [PATCH 36/59] update manual run bash --- pylint.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylint.bash b/pylint.bash index 6ed458cee..1e6403640 100644 --- a/pylint.bash +++ b/pylint.bash @@ -27,10 +27,10 @@ dict=/tmp/dict.txt cat "../SupportScripts/actions/pylint/default_dict.txt" >$dict cat ".pylint_dict.txt" >>$dict -# pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error spinnman +pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error spinnman # one test -pylint --enable=wrong-import-order --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman +# pylint --enable=wrong-import-order --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman # check docs # pylint --enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman From c14febafae01496a1157dffc9f716a533ad8b3e3 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 31 Jan 2024 10:18:56 +0000 Subject: [PATCH 37/59] flake8 --- spinnman/exceptions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spinnman/exceptions.py b/spinnman/exceptions.py index c8bf2ed61..220f7c80f 100644 --- a/spinnman/exceptions.py +++ b/spinnman/exceptions.py @@ -289,7 +289,8 @@ def __init__(self, error_requests: List[AbstractSCPRequest], f"{sdp_header.destination_chip_y,}:" \ f"{sdp_header.destination_cpu}{phys_p}]" problem += \ - f" Received exception class: {exception.__class__.__name__}\n" \ + f" Received exception class: " \ + f"{exception.__class__.__name__}\n" \ f" With message {str(exception)}\n" \ f" When sending to {location}\n" \ f" Stack trace: {traceback.format_tb(trace_back)}\n" From 7d3db03d1bf92515d4205ac045d1f9a2d10c2b30 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 31 Jan 2024 10:39:02 +0000 Subject: [PATCH 38/59] flake8 --- spinnman/exceptions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spinnman/exceptions.py b/spinnman/exceptions.py index 220f7c80f..a89962eb7 100644 --- a/spinnman/exceptions.py +++ b/spinnman/exceptions.py @@ -286,8 +286,8 @@ def __init__(self, error_requests: List[AbstractSCPRequest], location = f"board {connection.remote_ip_address} with ethernet " \ f"chip {connection.chip_x}:{connection.chip_y} " \ f"[{sdp_header.destination_chip_x}:" \ - f"{sdp_header.destination_chip_y,}:" \ - f"{sdp_header.destination_cpu}{phys_p}]" + f"{sdp_header.destination_chip_y}:" \ + f"{sdp_header.destination_cpu}({phys_p})]" problem += \ f" Received exception class: " \ f"{exception.__class__.__name__}\n" \ From 3cf4d67e3505f58984787a15c81ce3a25378cc38 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 2 Feb 2024 09:43:32 +0000 Subject: [PATCH 39/59] declare abstract methods of none declared super --- spinnman/extended/extended_transceiver.py | 28 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/spinnman/extended/extended_transceiver.py b/spinnman/extended/extended_transceiver.py index 58ac4c347..1d67ca57d 100644 --- a/spinnman/extended/extended_transceiver.py +++ b/spinnman/extended/extended_transceiver.py @@ -20,7 +20,9 @@ import random import struct import time -from spinn_utilities.abstract_base import AbstractBase +from spinn_utilities.overrides import overrides +from spinn_utilities.abstract_base import ( + AbstractBase, abstractmethod) from spinn_utilities.log import FormatAdapter from spinn_utilities.logger_utils import warn_once from spinn_utilities.require_subclass import require_subclass @@ -41,11 +43,12 @@ from spinnman.data import SpiNNManDataView from spinnman.messages.spinnaker_boot import SystemVariableDefinition from spinnman.processes import ( - GetHeapProcess, ReadMemoryProcess, SendSingleCommandProcess, - WriteMemoryProcess) + ConnectionSelector, GetHeapProcess, ReadMemoryProcess, + SendSingleCommandProcess, WriteMemoryProcess) from spinnman.transceiver.extendable_transceiver import ExtendableTransceiver _ONE_BYTE = struct.Struct("B") +_ONE_WORD = struct.Struct(" ConnectionSelector: + """ + Returns the scamp selector + + :rtype: AbstractMultiConnectionProcessConnectionSelector + """ + raise NotImplementedError def send_scp_message(self, message, connection=None): """ @@ -606,7 +626,7 @@ def get_router_diagnostic_filter( ROUTER_REGISTER_BASE_ADDRESS + ROUTER_FILTER_CONTROLS_OFFSET + position * ROUTER_DIAGNOSTIC_FILTER_SIZE) - process = SendSingleCommandProcess( + process: SendSingleCommandProcess = SendSingleCommandProcess( self.scamp_connection_selector) response = process.execute( ReadMemory((x, y, 0), memory_position, 4)) From 89be209c838edd416d29a27ac4789a93362c50a4 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 2 Feb 2024 09:44:22 +0000 Subject: [PATCH 40/59] type fixes --- spinnman/board_test_configuration.py | 8 ++++---- .../udp_packet_connections/ip_address_connection.py | 6 +++--- .../eieio/command_messages/eieio_command_header.py | 10 ++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/spinnman/board_test_configuration.py b/spinnman/board_test_configuration.py index 416c75df4..19ac94cd4 100644 --- a/spinnman/board_test_configuration.py +++ b/spinnman/board_test_configuration.py @@ -49,16 +49,16 @@ def set_up_remote_board(self, version: Optional[int] = None): """ if Ping.host_is_reachable("192.168.240.253"): self.remotehost = "192.168.240.253" - set_config("Machine", "version", 3) + set_config("Machine", "version", "3") self.auto_detect_bmp = False elif Ping.host_is_reachable("spinn-4.cs.man.ac.uk"): self.remotehost = "spinn-4.cs.man.ac.uk" - set_config("Machine", "version", 5) + set_config("Machine", "version", "5") elif Ping.host_is_reachable("192.168.240.1"): self.remotehost = "192.168.240.1" - set_config("Machine", "version", 5) + set_config("Machine", "version", "5") elif version is not None: self.remotehost = LOCAL_HOST - set_config("Machine", "version", version) + set_config("Machine", "version", str(version)) else: raise unittest.SkipTest("None of the test boards reachable") diff --git a/spinnman/connections/udp_packet_connections/ip_address_connection.py b/spinnman/connections/udp_packet_connections/ip_address_connection.py index 10788ac67..42b6ed142 100644 --- a/spinnman/connections/udp_packet_connections/ip_address_connection.py +++ b/spinnman/connections/udp_packet_connections/ip_address_connection.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. from contextlib import suppress -from typing import Optional, Tuple +from typing import Optional from spinnman.constants import UDP_BOOT_CONNECTION_DEFAULT_PORT from .udp_connection import UDPConnection @@ -31,12 +31,12 @@ def __init__(self, local_host=None, super().__init__(local_host=local_host, local_port=local_port) def receive_ip_address(self, timeout: Optional[float] = None - ) -> Optional[Tuple[bytes, Tuple[str, int]]]: + ) -> Optional[str]: """ :param timeout: :type timeout: float or None - :rtype: tuple(byte, tuple(str, int)) or None + :rtype: str or None """ with suppress(Exception): (_, (ip_address, port)) = self.receive_with_address(timeout) diff --git a/spinnman/messages/eieio/command_messages/eieio_command_header.py b/spinnman/messages/eieio/command_messages/eieio_command_header.py index d5e96fecf..cb1c3c125 100644 --- a/spinnman/messages/eieio/command_messages/eieio_command_header.py +++ b/spinnman/messages/eieio/command_messages/eieio_command_header.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Union +from typing import cast, Union import struct from enum import Enum from spinnman.exceptions import SpinnmanInvalidParameterException @@ -33,12 +33,14 @@ def __init__(self, command: Union[int, Enum]): :type command: int or Enum """ if isinstance(command, Enum): - command = command.value - if command < 0 or command >= 16384: + command_value = command.value + else: + command_value = cast(int, command) + if command_value < 0 or command_value >= 16384: raise SpinnmanInvalidParameterException( "command", command, "parameter command is outside the allowed range (0 to 16383)") - self._command = command + self._command = command_value @property def command(self) -> int: From dc014ee557037438192268221d152c4b79347c8d Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 2 Feb 2024 10:12:35 +0000 Subject: [PATCH 41/59] remove an overirdes as it would get rather complicated --- spinnman/extended/extended_transceiver.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spinnman/extended/extended_transceiver.py b/spinnman/extended/extended_transceiver.py index 1d67ca57d..055bbbf11 100644 --- a/spinnman/extended/extended_transceiver.py +++ b/spinnman/extended/extended_transceiver.py @@ -20,6 +20,7 @@ import random import struct import time +from typing import Optional from spinn_utilities.overrides import overrides from spinn_utilities.abstract_base import ( AbstractBase, abstractmethod) @@ -74,8 +75,7 @@ class ExtendedTransceiver(object, metaclass=AbstractBase): # pylint: disable=protected-access @abstractmethod - @overrides(ExtendableTransceiver._where_is_xy) - def _where_is_xy(self, x: int, y: int): + def _where_is_xy(self, x: int, y: int) -> Optional[str]: raise NotImplementedError @property From e9ca9c2277b882fbbd3771a95a556b6028bf4e71 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 2 Feb 2024 10:13:05 +0000 Subject: [PATCH 42/59] typing --- spinnman/transceiver/base_transceiver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spinnman/transceiver/base_transceiver.py b/spinnman/transceiver/base_transceiver.py index bfd7a5d05..bf2638e68 100644 --- a/spinnman/transceiver/base_transceiver.py +++ b/spinnman/transceiver/base_transceiver.py @@ -232,7 +232,7 @@ def bmp_selector(self) -> Optional[FixedConnectionSelector[BMPConnection]]: def scamp_connection_selector(self) -> MostDirectConnectionSelector: return self._scamp_connection_selector - def _where_is_xy(self, x: int, y: int): + def _where_is_xy(self, x: int, y: int) -> Optional[str]: """ Attempts to get where_is_x_y info from the machine From 890895fff35132629ee96569d1f6f484dc4444ed Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 2 Feb 2024 10:13:21 +0000 Subject: [PATCH 43/59] implement abstract methods --- unittests/test_transceiver.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/unittests/test_transceiver.py b/unittests/test_transceiver.py index 238c24453..d0584a830 100644 --- a/unittests/test_transceiver.py +++ b/unittests/test_transceiver.py @@ -32,6 +32,12 @@ class MockExtendedTransceiver(MockableTransceiver, ExtendedTransceiver): pass + def _where_is_xy(self, x: int, y: int) -> None: + return None + + def scamp_connection_selector(self): + raise NotImplementedError + class TestTransceiver(unittest.TestCase): From 824040b6e8ed3a82c6c863a346998d0e579f5c3b Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 2 Feb 2024 10:34:57 +0000 Subject: [PATCH 44/59] fix errors found by mypy --- spinnman/extended/extended_transceiver.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spinnman/extended/extended_transceiver.py b/spinnman/extended/extended_transceiver.py index 055bbbf11..ba02a965d 100644 --- a/spinnman/extended/extended_transceiver.py +++ b/spinnman/extended/extended_transceiver.py @@ -630,11 +630,11 @@ def get_router_diagnostic_filter( self.scamp_connection_selector) response = process.execute( ReadMemory((x, y, 0), memory_position, 4)) - return DiagnosticFilter.read_from_int(self._ONE_WORD.unpack_from( + return DiagnosticFilter.read_from_int(_ONE_WORD.unpack_from( response.data, response.offset)[0]) # pylint: disable=no-member except Exception: - logger.info(self.where_is_xy(x, y)) + logger.info(self._where_is_xy(x, y)) raise @property From 3b7f4eb9b1677a00c331f6bdbf91672e51520830 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 12 Feb 2024 15:47:30 +0000 Subject: [PATCH 45/59] small changes to avoid spelling exception --- spinnman/get_cores_in_run_state.py | 5 +++-- spinnman/transceiver/extendable_transceiver.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/spinnman/get_cores_in_run_state.py b/spinnman/get_cores_in_run_state.py index 10b71458d..1dcf930a5 100644 --- a/spinnman/get_cores_in_run_state.py +++ b/spinnman/get_cores_in_run_state.py @@ -78,8 +78,9 @@ def _make_transceiver(host, version, bmp_names) -> Transceiver: :param version: Board version to use (`None` defaults to 5 unless host is 192.168.240.253 (spin 3) :type version: int or None - :param bmp: bmp connection or `None` to auto detect (if applicable) - :type bmp: str or None + :param bmp_names: names of BMP connection + or `None` to auto detect (if applicable) + :type bmp_names: str or None :rtype: Transceiver """ if host is None: diff --git a/spinnman/transceiver/extendable_transceiver.py b/spinnman/transceiver/extendable_transceiver.py index e937f82bc..953ce9886 100644 --- a/spinnman/transceiver/extendable_transceiver.py +++ b/spinnman/transceiver/extendable_transceiver.py @@ -53,7 +53,7 @@ def __init__(self): @abstractmethod def bmp_selector(self) -> Optional[FixedConnectionSelector[BMPConnection]]: """ - Returns the bmp selector + Returns the BMP selector :rtype: AbstractMultiConnectionProcessConnectionSelector """ From b89ddab0a810c2c11138cf23f563a96f8259c356 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 12 Feb 2024 15:47:51 +0000 Subject: [PATCH 46/59] move spelling exceptions to support scripts --- .pylint_dict.txt | 31 +++---------------------------- pylint.bash | 11 +++-------- 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/.pylint_dict.txt b/.pylint_dict.txt index 9392a8031..adce7d510 100644 --- a/.pylint_dict.txt +++ b/.pylint_dict.txt @@ -12,34 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Our abbreviations/names -bmp -bmpc -Spalloc -ybug +# We use a single exception files for all the main repsitories +# It can be found at: +# https://github.com/SpiNNakerManchester/SupportScripts/blob/master/actions/pylint/default_dict.txt -# Our special words -keepalive -# Python packages -websocket - -# Python types -BufferedIOBase -CPUInfo -CPUInfos -DiagnosticFilter -DiagnosticFilterDestination -DiagnosticFilterDefaultRoutingStatus -DiagnosticFilterEmergencyRoutingStatus -DiagnosticFilterPacketType -DiagnosticFilterPayloadStatus -DiagnosticFilterSource -HeapElement -PreparedRequest -SCPResult -SpallocMachine -SpinnakerBootMessage -SystemVariableDefinition -WebSocket diff --git a/pylint.bash b/pylint.bash index 1e6403640..f5e17dd70 100644 --- a/pylint.bash +++ b/pylint.bash @@ -22,16 +22,11 @@ # requires the spelling dicts # sudo apt-get -o Dpkg::Use-Pty=0 install --fix-missing enchant-2 hunspell hunspell-en-gb -dict=/tmp/dict.txt - -cat "../SupportScripts/actions/pylint/default_dict.txt" >$dict -cat ".pylint_dict.txt" >>$dict - -pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=import-error spinnman +pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file="../SupportScripts/actions/pylint/default_dict.txt" --disable=import-error spinnman # one test -# pylint --enable=wrong-import-order --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman +# pylint --enable=wrong-import-order --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file="../SupportScripts/actions/pylint/default_dict.txt" --disable=all spinnman # check docs -# pylint --enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file=$dict --disable=all spinnman +# pylint --enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file="../SupportScripts/actions/pylint/default_dict.txt" --disable=all spinnman From c13c74b88114cc4560a8ac11018ab4fd9e83af24 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 15 Feb 2024 16:53:30 +0000 Subject: [PATCH 47/59] Allow numbers in the middle of constant names --- spinnman/model/cpu_info.py | 1 - 1 file changed, 1 deletion(-) diff --git a/spinnman/model/cpu_info.py b/spinnman/model/cpu_info.py index f8ed2ee62..bf8787b6e 100644 --- a/spinnman/model/cpu_info.py +++ b/spinnman/model/cpu_info.py @@ -19,7 +19,6 @@ #: Size of `vcpu_t` in SARK. CPU_INFO_BYTES = 128 -# pylint: disable=invalid-name CPU_USER_0_START_ADDRESS = 112 #: Offset into data of byte of processor state field. STATE_FIELD_OFFSET = 48 From f5c05cda6deac5a93857e1e854109d47751029ce Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 16 Feb 2024 06:48:18 +0000 Subject: [PATCH 48/59] use pylint rcfile in SupportScripts --- .pylintrc | 469 ------------------------------------------------------ 1 file changed, 469 deletions(-) delete mode 100644 .pylintrc diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index 2d054cde5..000000000 --- a/.pylintrc +++ /dev/null @@ -1,469 +0,0 @@ -# Copyright (c) 2019 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. - -[MASTER] - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code -extension-pkg-whitelist=numpy - -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS - -# Add files or directories matching the regex patterns to the blacklist. The -# regex matches against base names, not paths. -ignore-patterns= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Use multiple processes to speed up Pylint. -jobs=1 - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins= - -# Pickle collected data for later comparisons. -persistent=yes - -# Specify a configuration file. -#rcfile= - -# When enabled, pylint would attempt to guess common misconfiguration and emit -# user-friendly hints instead of false-positive error messages -suggestion-mode=yes - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once).You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use"--disable=all --enable=classes -# --disable=W" -disable=R,C - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable=c-extension-no-member,C0402,C0403 - - -[REPORTS] - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details -#msg-template= - -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio).You can also give a reporter class, eg -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Tells whether to display a full report or only the messages -reports=no - -# Activate the evaluation score. -score=yes - - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - -# Complete name of functions that never returns. When checking for -# inconsistent-return-statements if a never returning function is called then -# it will be considered as an explicit return statement and no message will be -# printed. -never-returning-functions=optparse.Values,sys.exit - - -[BASIC] - -# Naming style matching correct argument names -argument-naming-style=snake_case - -# Regular expression matching correct argument names. Overrides argument- -# naming-style -#argument-rgx= - -# Naming style matching correct attribute names -attr-naming-style=snake_case - -# Regular expression matching correct attribute names. Overrides attr-naming- -# style -#attr-rgx= - -# Bad variable names which should always be refused, separated by a comma -bad-names=foo, - bar, - baz, - toto, - tutu, - tata - -# Naming style matching correct class attribute names -class-attribute-naming-style=any - -# Regular expression matching correct class attribute names. Overrides class- -# attribute-naming-style -#class-attribute-rgx= - -# Naming style matching correct class names -class-naming-style=PascalCase - -# Regular expression matching correct class names. Overrides class-naming-style -#class-rgx= - -# Naming style matching correct constant names -const-naming-style=UPPER_CASE - -# Regular expression matching correct constant names. Overrides const-naming- -# style -#const-rgx= - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - -# Naming style matching correct function names -function-naming-style=snake_case - -# Regular expression matching correct function names. Overrides function- -# naming-style -#function-rgx= - -# Good variable names which should always be accepted, separated by a comma -good-names=i, - j, - k, - ex, - Run, - _ - -# Include a hint for the correct naming format with invalid-name -include-naming-hint=no - -# Naming style matching correct inline iteration names -inlinevar-naming-style=any - -# Regular expression matching correct inline iteration names. Overrides -# inlinevar-naming-style -#inlinevar-rgx= - -# Naming style matching correct method names -method-naming-style=snake_case - -# Regular expression matching correct method names. Overrides method-naming- -# style -#method-rgx= - -# Naming style matching correct module names -module-naming-style=snake_case - -# Regular expression matching correct module names. Overrides module-naming- -# style -#module-rgx= - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -property-classes=abc.abstractproperty - -# Naming style matching correct variable names -variable-naming-style=snake_case - -# Regular expression matching correct variable names. Overrides variable- -# naming-style -#variable-rgx= - - -[FORMAT] - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -expected-line-ending-format= - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Maximum number of characters on a single line. -max-line-length=100 - -# Maximum number of lines in a module -max-module-lines=1000 - -# Allow the body of a class to be on the same line as the declaration if body -# contains single statement. -single-line-class-stmt=no - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - - -[LOGGING] - -# Logging modules to check that the string format arguments are in logging -# function parameter format -logging-modules=logging,FormatAdapter - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME, - XXX - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=no - -# Minimum lines number of a similarity. -min-similarity-lines=4 - - -[SPELLING] - -# Limits count of emitted suggestions for spelling mistakes -max-spelling-suggestions=4 - -# Spelling dictionary name. Available dictionaries: none. To make it working -# install python-enchant package. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to indicated private dictionary in -# --spelling-private-dict-file option instead of raising a message. -spelling-store-unknown-words=no - - -[TYPECHECK] - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members=numpy.* - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local,numpy - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis. It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules=numpy - -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes - -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 - -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 - - -[VARIABLES] - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins= - -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_, - _cb - -# A regular expression matching the name of dummy variables (i.e. expectedly -# not used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore -ignored-argument-names=_.*|^ignored_|^unused_ - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__, - __new__, - _hard_reset, - - setUp - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict, - _fields, - _replace, - _source, - _make - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=mcs - - -[DESIGN] - -# Maximum number of arguments for function / method -max-args=5 - -# Maximum number of attributes for a class (see R0902). -max-attributes=7 - -# Maximum number of boolean expressions in a if statement -max-bool-expr=5 - -# Maximum number of branch for function / method body -max-branches=12 - -# Maximum number of locals for function / method body -max-locals=15 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of return / yield for function / method body -max-returns=6 - -# Maximum number of statements in function / method body -max-statements=50 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - - -[IMPORTS] - -# Allow wildcard imports from modules that define __all__. -allow-wildcard-with-all=no - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - -# Deprecated modules which should not be used, separated by a comma -deprecated-modules=optparse,tkinter.tix - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled) -ext-import-graph= - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled) -import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled) -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception" -overgeneral-exceptions=builtins.Exception From c845b24b7524477835fbce026164606c40ccfe2c Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 16 Feb 2024 06:53:40 +0000 Subject: [PATCH 49/59] Allow numbers in the middle of constant names --- spinnman/constants.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spinnman/constants.py b/spinnman/constants.py index 8f6ae5b0f..f36f090f3 100644 --- a/spinnman/constants.py +++ b/spinnman/constants.py @@ -15,7 +15,6 @@ from enum import Enum from typing import Dict, Tuple -# pylint: disable=invalid-name LOCAL_HOST = "127.0.0.1" #: the amount of time to wait in seconds between powering off and powering @@ -108,6 +107,7 @@ class EIEIO_COMMAND_IDS(Enum): + # pylint: disable=invalid-name """ A listing of what SpiNNaker specific EIEIO commands there are. """ @@ -140,6 +140,7 @@ class EIEIO_COMMAND_IDS(Enum): class IPTAG_TIME_OUT_WAIT_TIMES(Enum): + # pylint: disable=invalid-name """ The values used by the SCP IP tag time outs. These control how long to wait for any message request which requires a response, before raising an error. @@ -160,6 +161,7 @@ class IPTAG_TIME_OUT_WAIT_TIMES(Enum): class ROUTER_REGISTER_REGISTERS(Enum): + # pylint: disable=invalid-name """ The indices to the router registers. """ @@ -182,6 +184,7 @@ class ROUTER_REGISTER_REGISTERS(Enum): class READ_TYPES(Enum): + # pylint: disable=invalid-name """ The types of read available from SARK. These values are used to tell SARK how to read the data in a time efficient manner. From b843b5e6887cbc1bff5bc4181eadae1f65b6ccf1 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 16 Feb 2024 12:33:36 +0000 Subject: [PATCH 50/59] temporarily add other spinnaker repositories --- import_hook.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 import_hook.py diff --git a/import_hook.py b/import_hook.py new file mode 100644 index 000000000..01a2d6900 --- /dev/null +++ b/import_hook.py @@ -0,0 +1,25 @@ +# Copyright (c) 2017 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. + +""" +This file is imported by init-hook in the rcfile +https://github.com/SpiNNakerManchester/SupportScripts/blob/master/actions/pylint/strict_rcfile + +It allows you to temporarily add the other spinnaker repositories without making them part of the permemnant python path + +Intended for use when running pylint.bash +""" +import sys +sys.path.append("../SpiNNUtils") +sys.path.append("../SpiNNMachine") \ No newline at end of file From ca7e2a393a9d394562995e877ca2d4b8910f3205 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 16 Feb 2024 12:33:50 +0000 Subject: [PATCH 51/59] cleaner bash --- pylint.bash | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pylint.bash b/pylint.bash index f5e17dd70..19336137c 100644 --- a/pylint.bash +++ b/pylint.bash @@ -22,11 +22,16 @@ # requires the spelling dicts # sudo apt-get -o Dpkg::Use-Pty=0 install --fix-missing enchant-2 hunspell hunspell-en-gb -pylint --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file="../SupportScripts/actions/pylint/default_dict.txt" --disable=import-error spinnman - +rcfile="--rcfile=../SupportScripts/actions/pylint/strict_rcfile" +dict="--spelling-private-dict-file=../SupportScripts/actions/pylint/default_dict.txt" +params="--output-format=colorized --disable=R --persistent=no --jobs=1 --spelling-dict=en_GB" +check= # one test -# pylint --enable=wrong-import-order --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file="../SupportScripts/actions/pylint/default_dict.txt" --disable=all spinnman - +# check="--enable=wrong-import-order --disable=all" # check docs -# pylint --enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --output-format=colorized --disable=R --persistent=no --jobs=1 --rcfile=../SupportScripts/actions/pylint/strict_rcfile --spelling-dict=en_GB --spelling-private-dict-file="../SupportScripts/actions/pylint/default_dict.txt" --disable=all spinnman +check="--enable=missing-function-docstring,missing-class-docstring,invalid-characters-in-docstring,wrong-spelling-in-comment,wrong-spelling-in-docstring --disable=all" + +pylint $check $rcfile $dict $params spinnman + + From 0cb0c238108710e16c942c7712e085e248dea47d Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 29 Feb 2024 06:41:35 +0000 Subject: [PATCH 52/59] use SupportScripts/actions/pylint/strict_rcfile for pylint --- .github/workflows/python_actions.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index ec8ed5010..bfa4b0f19 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -67,6 +67,7 @@ jobs: package: spinnman exitcheck: 31 # Action fails on any message language: en_GB + rcfile: global_strict - name: Lint with mypy run: mypy spinnman From 1ec37e510383ebe5e25fdd922222be65016089fa Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 29 Feb 2024 06:59:37 +0000 Subject: [PATCH 53/59] fix spellings in comments --- spinnman/model/enums/run_time_error.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spinnman/model/enums/run_time_error.py b/spinnman/model/enums/run_time_error.py index c4ea0a83c..c60e13e4c 100644 --- a/spinnman/model/enums/run_time_error.py +++ b/spinnman/model/enums/run_time_error.py @@ -53,7 +53,7 @@ class RunTimeError(Enum): ENABLE = 15 #: Generic null pointer error NULL = 16 - #: Pkt startup failure + #: Packet startup failure PKT = 17 #: Timer startup failure TIMER = 18 From a2b8caecf56cf408b84bb49c1a7585f9d4b6ceb0 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 1 Mar 2024 15:15:40 +0000 Subject: [PATCH 54/59] split Chip processors between user and monitor --- spinnman/transceiver/base_transceiver.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/spinnman/transceiver/base_transceiver.py b/spinnman/transceiver/base_transceiver.py index bf2a20acc..af84ae8ed 100644 --- a/spinnman/transceiver/base_transceiver.py +++ b/spinnman/transceiver/base_transceiver.py @@ -708,9 +708,8 @@ def get_cpu_infos( if core_subsets is None: core_subsets = CoreSubsets() for chip in SpiNNManDataView.get_machine().chips: - for processor in chip.processors: - core_subsets.add_processor( - chip.x, chip.y, processor.processor_id) + for p in chip.all_processor_ids: + core_subsets.add_processor(chip.x, chip.y, p) if states is None: process = GetCPUInfoProcess(self._scamp_connection_selector) @@ -806,9 +805,8 @@ def get_iobuf(self, core_subsets: Optional[CoreSubsets] = None if core_subsets is None: core_subsets = CoreSubsets() for chip in SpiNNManDataView.get_machine().chips: - for processor in chip.processors: - core_subsets.add_processor( - chip.x, chip.y, processor.processor_id) + for p in chip.all_processor_ids: + core_subsets.add_processor(chip.x, chip.y, p) # read iobuf from machine process = ReadIOBufProcess(self._scamp_connection_selector) From 7fb3af42af6fac631606afd60abd72506d7a981f Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 5 Mar 2024 12:15:55 +0000 Subject: [PATCH 55/59] remove send_scp_request --- .../abstract_scp_connection.py | 23 ----- .../udp_packet_connections/bmp_connection.py | 4 - .../scamp_connection.py | 18 ---- spinnman/extended/extended_transceiver.py | 28 ------- spinnman/spalloc/spalloc_scp_connection.py | 4 - .../connection_tests/test_udp_connection.py | 84 ------------------- 6 files changed, 161 deletions(-) delete mode 100644 unittests/connection_tests/test_udp_connection.py diff --git a/spinnman/connections/abstract_classes/abstract_scp_connection.py b/spinnman/connections/abstract_classes/abstract_scp_connection.py index 3168f47d7..8b05f40a4 100644 --- a/spinnman/connections/abstract_classes/abstract_scp_connection.py +++ b/spinnman/connections/abstract_classes/abstract_scp_connection.py @@ -66,29 +66,6 @@ def get_scp_data(self, scp_request: AbstractSCPRequest) -> bytes: """ raise NotImplementedError - @abstractmethod - def send_scp_request(self, scp_request: AbstractSCPRequest): - """ - Sends an SCP request down this connection. - - Messages must have the following properties: - - * source_port is `None` or 7 - * source_cpu is `None` or 31 - * source_chip_x is `None` or 0 - * source_chip_y is `None` or 0 - - tag in the message is optional; if not set, the default set in the - constructor will be used. - sequence in the message is optional; if not set, (sequence number - last assigned + 1) % 65536 will be used - - :param AbstractSCPRequest scp_request: message packet to send - :raise SpinnmanIOException: - If there is an error sending the message - """ - raise NotImplementedError - @property @abstractmethod def chip_x(self) -> int: diff --git a/spinnman/connections/udp_packet_connections/bmp_connection.py b/spinnman/connections/udp_packet_connections/bmp_connection.py index b85a4c176..4b123b85b 100644 --- a/spinnman/connections/udp_packet_connections/bmp_connection.py +++ b/spinnman/connections/udp_packet_connections/bmp_connection.py @@ -83,10 +83,6 @@ def receive_scp_response(self, timeout: Optional[float] = 1.0) -> Tuple[ result, sequence = _TWO_SHORTS.unpack_from(data, 10) return SCPResult(result), sequence, data, 2 - @overrides(AbstractSCPConnection.send_scp_request) - def send_scp_request(self, scp_request: AbstractSCPRequest): - self.send(self.get_scp_data(scp_request)) - def __repr__(self): return ( f"BMPConnection(" diff --git a/spinnman/connections/udp_packet_connections/scamp_connection.py b/spinnman/connections/udp_packet_connections/scamp_connection.py index 9ae9f70bf..738317d4d 100644 --- a/spinnman/connections/udp_packet_connections/scamp_connection.py +++ b/spinnman/connections/udp_packet_connections/scamp_connection.py @@ -114,24 +114,6 @@ def receive_scp_response_with_address( result, sequence = _TWO_SHORTS.unpack_from(data, 10) return SCPResult(result), sequence, data, 2, addr, port - @overrides(AbstractSCPConnection.send_scp_request) - def send_scp_request(self, scp_request: AbstractSCPRequest): - self.send(self.get_scp_data(scp_request)) - - def send_scp_request_to( - self, scp_request: AbstractSCPRequest, - x: int, y: int, ip_address: str): - """ - - :param AbstractSCPRequest scp_request: - :param int x: - :param int y: - :param str ip_address: - """ - self.send_to( - self.get_scp_data(scp_request, x, y), - (str(ip_address), SCP_SCAMP_PORT)) - def __repr__(self) -> str: return ( f"SCAMPConnection(chip_x={self._chip_x}, chip_y={self._chip_y}, " diff --git a/spinnman/extended/extended_transceiver.py b/spinnman/extended/extended_transceiver.py index ba02a965d..bc412cce4 100644 --- a/spinnman/extended/extended_transceiver.py +++ b/spinnman/extended/extended_transceiver.py @@ -89,34 +89,6 @@ def scamp_connection_selector(self) -> ConnectionSelector: """ raise NotImplementedError - def send_scp_message(self, message, connection=None): - """ - Sends an SCP message, without expecting a response. - - :param message: The message to send - :type message: - spinnman.messages.scp.abstract_messages.AbstractSCPRequest - :param SCAMPConnection connection: - The connection to use (omit to pick a random one) - :raise SpinnmanTimeoutException: - If there is a timeout before a message is received - :raise SpinnmanInvalidParameterException: - If one of the fields of the received message is invalid - :raise SpinnmanInvalidPacketException: - * If the message is not a recognised packet type - * If a packet is received that is not a valid response - :raise SpinnmanUnsupportedOperationException: - If no connection can send the type of message given - :raise SpinnmanIOException: - If there is an error sending the message or receiving the response - :raise SpinnmanUnexpectedResponseCodeException: - If the response is not one of the expected codes - """ - if connection is None: - connection = self.scamp_connections[random.randint( - 0, len(self.scamp_connections) - 1)] - connection.send_scp_request(message) - def is_connected(self, connection=None): """ Determines if the board can be contacted via SCAMP diff --git a/spinnman/spalloc/spalloc_scp_connection.py b/spinnman/spalloc/spalloc_scp_connection.py index bfd42d377..6b2bff7a0 100644 --- a/spinnman/spalloc/spalloc_scp_connection.py +++ b/spinnman/spalloc/spalloc_scp_connection.py @@ -61,10 +61,6 @@ def receive_scp_response(self, timeout: Optional[float] = 1.0) -> Tuple[ result, sequence = _TWO_SHORTS.unpack_from(data, 10) return SCPResult(result), sequence, data, 2 - @overrides(SCAMPConnection.send_scp_request) - def send_scp_request(self, scp_request: AbstractSCPRequest): - self.send(self.get_scp_data(scp_request)) - @overrides(SCAMPConnection.get_scp_data) def get_scp_data( self, scp_request: AbstractSCPRequest, diff --git a/unittests/connection_tests/test_udp_connection.py b/unittests/connection_tests/test_udp_connection.py deleted file mode 100644 index a417d5330..000000000 --- a/unittests/connection_tests/test_udp_connection.py +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright (c) 2014 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. - -import unittest -from spinnman.connections.udp_packet_connections import SCAMPConnection -from spinnman.config_setup import unittest_setup -from spinnman.constants import LOCAL_HOST -from spinnman.exceptions import SpinnmanTimeoutException -from spinnman.messages.scp.impl import GetVersion, ReadLink, ReadMemory -from spinnman.messages.scp.enums import SCPResult -from spinnman.messages.scp.impl.get_version_response import GetVersionResponse -from spinnman.board_test_configuration import BoardTestConfiguration - - -class TestUDPConnection(unittest.TestCase): - - def setUp(self): - unittest_setup() - self.board_config = BoardTestConfiguration() - - def test_scp_version_request_and_response_board(self): - self.board_config.set_up_remote_board(version=5) - connection = SCAMPConnection( - remote_host=self.board_config.remotehost) - scp_req = GetVersion(0, 0, 0) - scp_response = GetVersionResponse() - connection.send_scp_request(scp_req) - if self.board_config.remotehost == LOCAL_HOST: - raise unittest.SkipTest( - "Can not test the rest without a ral board") - _, _, data, offset = connection.receive_scp_response() - scp_response.read_bytestring(data, offset) - print(scp_response.version_info) - self.assertEqual( - scp_response._scp_response_header._result, SCPResult.RC_OK) - - def test_scp_read_link_request_and_response_board(self): - self.board_config.set_up_remote_board(version=5) - connection = SCAMPConnection( - remote_host=self.board_config.remotehost) - scp_link = ReadLink((0, 0, 0), 0, 0x70000000, 250) - connection.send_scp_request(scp_link) - if self.board_config.remotehost == LOCAL_HOST: - raise unittest.SkipTest( - "Can not test the rest without a ral board") - result, _, _, _ = connection.receive_scp_response() - self.assertEqual(result, SCPResult.RC_OK) - - def test_scp_read_memory_request_and_response_board(self): - self.board_config.set_up_remote_board(version=5) - connection = SCAMPConnection( - remote_host=self.board_config.remotehost) - scp_link = ReadMemory((0, 0, 0), 0x70000000, 256) - connection.send_scp_request(scp_link) - if self.board_config.remotehost == LOCAL_HOST: - raise unittest.SkipTest( - "Can not test the rest without a ral board") - result, _, _, _ = connection.receive_scp_response() - self.assertEqual(result, SCPResult.RC_OK) - - def test_send_scp_request_to_nonexistent_host(self): - # Microsoft invalid IP address. For more details see: - # https://answers.microsoft.com/en-us/windows/forum/windows_vista-networking/invalid-ip-address-169254xx/ce096728-e2b7-4d54-80cc-52a4ed342870 - _NOHOST = "169.254.254.254" - with self.assertRaises(SpinnmanTimeoutException): - connection = SCAMPConnection(remote_host=_NOHOST) - scp = ReadMemory((0, 0, 0), 0, 256) - connection.send_scp_request(scp) - _, _, _, _ = connection.receive_scp_response(2) - - -if __name__ == '__main__': - unittest.main() From 998350d8e66f9f7f013106ac99dded7db24df888 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 5 Mar 2024 12:21:00 +0000 Subject: [PATCH 56/59] remove unused import --- spinnman/extended/extended_transceiver.py | 1 - 1 file changed, 1 deletion(-) diff --git a/spinnman/extended/extended_transceiver.py b/spinnman/extended/extended_transceiver.py index bc412cce4..3d5fb272f 100644 --- a/spinnman/extended/extended_transceiver.py +++ b/spinnman/extended/extended_transceiver.py @@ -17,7 +17,6 @@ import io import os import logging -import random import struct import time from typing import Optional From 20ec99ba96f349671f007b1a98bbb3864d064111 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 12 Mar 2024 15:08:32 +0000 Subject: [PATCH 57/59] a chip is also an (x,y) --- spinnman/processes/application_copy_run_process.py | 8 ++++---- spinnman/transceiver/base_transceiver.py | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/spinnman/processes/application_copy_run_process.py b/spinnman/processes/application_copy_run_process.py index ebc05fd56..346253e92 100644 --- a/spinnman/processes/application_copy_run_process.py +++ b/spinnman/processes/application_copy_run_process.py @@ -54,7 +54,7 @@ def _get_next_chips( on_same_board = _on_same_board(chip, chip_xy) eth = (chip.nearest_ethernet_x, chip.nearest_ethernet_y) if (eth not in chips_done or - (chip.x, chip.y) not in chips_done[eth]): + chip not in chips_done[eth]): if on_same_board or not off_board_copy_done: next_chips.append(chip) if not on_same_board: @@ -119,19 +119,19 @@ def run(self, size: int, app_id: int, core_subsets: CoreSubsets, boot_chip = machine.boot_chip chips_done: Mapping[Tuple[int, int], List[Tuple[int, int]]] = \ defaultdict(list) - chips_done[boot_chip.x, boot_chip.y].append((boot_chip.x, boot_chip.y)) + chips_done[boot_chip].append((boot_chip)) parent_chips = _compute_parent_chips(machine) next_chips = _get_next_chips(chips_done, parent_chips, machine) while next_chips: # Do all the chips at the current level for chip in next_chips: - subset = core_subsets.get_core_subset_for_chip(chip.x, chip.y) + subset = core_subsets.get_core_subset_for_chip(chip) self._send_request(AppCopyRun( chip.x, chip.y, cast(int, chip.parent_link), size, app_id, subset.processor_ids, checksum, wait)) eth = (chip.nearest_ethernet_x, chip.nearest_ethernet_y) - chips_done[eth].append((chip.x, chip.y)) + chips_done[eth].append(chip) self._finish() self.check_for_error() next_chips = _get_next_chips(chips_done, parent_chips, machine) diff --git a/spinnman/transceiver/base_transceiver.py b/spinnman/transceiver/base_transceiver.py index 3c699942c..67f440c76 100644 --- a/spinnman/transceiver/base_transceiver.py +++ b/spinnman/transceiver/base_transceiver.py @@ -816,11 +816,9 @@ def get_core_state_count( self, app_id: int, state: CPUState, xys: Optional[Iterable[Tuple[int, int]]] = None) -> int: process = GetNCoresInStateProcess(self._scamp_connection_selector) - chip_xys = xys if xys is None: machine = SpiNNManDataView.get_machine() - chip_xys = [(ch.x, ch.y) - for ch in machine.ethernet_connected_chips] + chip_xys = machine.ethernet_connected_chips else: chip_xys = xys return process.get_n_cores_in_state(chip_xys, app_id, state) From a0833f86170bbed55bafda698c296af165f3d26b Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 12 Mar 2024 15:21:15 +0000 Subject: [PATCH 58/59] typing --- spinnman/processes/application_copy_run_process.py | 2 +- spinnman/transceiver/base_transceiver.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/spinnman/processes/application_copy_run_process.py b/spinnman/processes/application_copy_run_process.py index 346253e92..33c80a538 100644 --- a/spinnman/processes/application_copy_run_process.py +++ b/spinnman/processes/application_copy_run_process.py @@ -126,7 +126,7 @@ def run(self, size: int, app_id: int, core_subsets: CoreSubsets, while next_chips: # Do all the chips at the current level for chip in next_chips: - subset = core_subsets.get_core_subset_for_chip(chip) + subset = core_subsets.get_core_subset_for_chip(chip.x, chip.y) self._send_request(AppCopyRun( chip.x, chip.y, cast(int, chip.parent_link), size, app_id, subset.processor_ids, checksum, wait)) diff --git a/spinnman/transceiver/base_transceiver.py b/spinnman/transceiver/base_transceiver.py index 67f440c76..fa0b83ad7 100644 --- a/spinnman/transceiver/base_transceiver.py +++ b/spinnman/transceiver/base_transceiver.py @@ -816,6 +816,7 @@ def get_core_state_count( self, app_id: int, state: CPUState, xys: Optional[Iterable[Tuple[int, int]]] = None) -> int: process = GetNCoresInStateProcess(self._scamp_connection_selector) + chip_xys: Iterable[Tuple[int, int]] if xys is None: machine = SpiNNManDataView.get_machine() chip_xys = machine.ethernet_connected_chips From f32b7e71dd69b4744b9b7deb138c70d1459c8956 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Wed, 13 Mar 2024 06:27:38 +0000 Subject: [PATCH 59/59] remove hard coded n processors --- spinnman/get_cores_in_run_state.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spinnman/get_cores_in_run_state.py b/spinnman/get_cores_in_run_state.py index 1dcf930a5..2c55a2c55 100644 --- a/spinnman/get_cores_in_run_state.py +++ b/spinnman/get_cores_in_run_state.py @@ -48,7 +48,8 @@ def get_cores_in_run_state(txrx, app_id, print_all_chips): all_cores = [] for chip in machine.chips: - all_cores.append(CoreSubset(chip.x, chip.y, range(1, 17))) + all_cores.append(CoreSubset( + chip.x, chip.y, chip.placable_processors_ids)) all_cores = CoreSubsets(core_subsets=all_cores)