From bc840a5d5ffa3af6168de57ced4580da3d5f826b Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 26 Sep 2023 09:17:11 +0100 Subject: [PATCH] fix merge and types --- spinnman/spalloc/spalloc_job.py | 24 +++++++++++++++++++++--- spinnman/transceiver.py | 3 ++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/spinnman/spalloc/spalloc_job.py b/spinnman/spalloc/spalloc_job.py index b4b1c7785..ab70d64e5 100644 --- a/spinnman/spalloc/spalloc_job.py +++ b/spinnman/spalloc/spalloc_job.py @@ -13,7 +13,7 @@ # limitations under the License. from contextlib import AbstractContextManager -from typing import Dict, Tuple, Mapping +from typing import Dict, Mapping, Optional, Tuple from spinn_utilities.abstract_base import AbstractBase, abstractmethod from spinnman.constants import SCP_SCAMP_PORT from spinnman.transceiver import Transceiver @@ -40,15 +40,17 @@ def get_state(self) -> SpallocState: :rtype: SpallocState """ + raise NotImplementedError() @abstractmethod - def get_root_host(self) -> str: + def get_root_host(self) -> Optional[str]: """ Get the IP address for talking to the machine. :return: The IP address, or ``None`` if not allocated. :rtype: str or None """ + raise NotImplementedError() @abstractmethod def get_connections(self) -> Dict[Tuple[int, int], str]: @@ -58,6 +60,7 @@ def get_connections(self) -> Dict[Tuple[int, int], str]: :return: (x,y)->IP mapping, or ``None`` if not allocated :rtype: dict(tuple(int,int), str) or None """ + raise NotImplementedError() @abstractmethod def connect_to_board( @@ -72,6 +75,7 @@ def connect_to_board( :return: A connection that talks to the board. :rtype: SpallocProxiedConnection """ + raise NotImplementedError() @abstractmethod def connect_for_booting(self) -> SpallocBootConnection: @@ -81,6 +85,7 @@ def connect_for_booting(self) -> SpallocBootConnection: :return: a boot connection :rtype: SpallocBootConnection """ + raise NotImplementedError() @abstractmethod def open_eieio_connection(self, x: int, y: int) -> SpallocEIEIOConnection: @@ -94,6 +99,7 @@ def open_eieio_connection(self, x: int, y: int) -> SpallocEIEIOConnection: :return: an EIEIO connection with a board address bound :rtype: SpallocEIEIOConnection """ + raise NotImplementedError() @abstractmethod def open_eieio_listener_connection(self) -> SpallocEIEIOListener: @@ -106,6 +112,7 @@ def open_eieio_listener_connection(self) -> SpallocEIEIOListener: :return: an EIEIO connection with no board address bound :rtype: SpallocEIEIOListener """ + raise NotImplementedError() @abstractmethod def open_udp_listener_connection(self) -> UDPConnection: @@ -118,6 +125,7 @@ def open_udp_listener_connection(self) -> UDPConnection: :return: a UDP connection with no board address bound :rtype: UDPConnection """ + raise NotImplementedError() @abstractmethod def create_transceiver(self) -> Transceiver: @@ -127,6 +135,7 @@ def create_transceiver(self) -> Transceiver: :rtype: Transceiver """ + raise NotImplementedError() @abstractmethod def wait_for_state_change(self, old_state: SpallocState) -> SpallocState: @@ -141,6 +150,7 @@ def wait_for_state_change(self, old_state: SpallocState) -> SpallocState: If the machine gets destroyed, this will not wait for it. :rtype: SpallocState """ + raise NotImplementedError() @abstractmethod def wait_until_ready(self): @@ -149,6 +159,7 @@ def wait_until_ready(self): :raises Exception: If the allocation is destroyed """ + raise NotImplementedError() @abstractmethod def destroy(self, reason: str = "finished"): @@ -157,12 +168,14 @@ def destroy(self, reason: str = "finished"): :param str reason: Why the job is being destroyed. """ + raise NotImplementedError() @abstractmethod def keepalive(self): """ Signal the job that we want it to stay alive for a while longer. """ + raise NotImplementedError() @abstractmethod def launch_keepalive_task( @@ -178,9 +191,11 @@ def launch_keepalive_task( Some kind of closable task handle; closing it terminates the task. Destroying the job will also terminate the task. """ + raise NotImplementedError() @abstractmethod - def where_is_machine(self, x: int, y: int) -> Tuple[int, int, int]: + def where_is_machine(self, x: int, y: int) -> Optional[ + Tuple[int, int, int]]: """ Get the *physical* coordinates of the board hosting the given chip. @@ -191,6 +206,7 @@ def where_is_machine(self, x: int, y: int) -> Tuple[int, int, int]: the chip lies outside the allocation. :rtype: tuple(int,int,int) or None """ + raise NotImplementedError() @abstractmethod def get_session_credentials_for_db(self) -> Mapping[str, str]: @@ -201,6 +217,8 @@ def get_session_credentials_for_db(self) -> Mapping[str, str]: May assume that there is a ``proxy_configuration`` table with ``kind``, ``name`` and ``value`` columns. """ + raise NotImplementedError() + def __enter__(self): """ Return self on entering context. diff --git a/spinnman/transceiver.py b/spinnman/transceiver.py index 4a3f4006b..f704beac5 100644 --- a/spinnman/transceiver.py +++ b/spinnman/transceiver.py @@ -1552,7 +1552,8 @@ def wait_for_cores_to_be_in_state( if len(cores_not_in_state) != 0: self.__log_where_is_info(cores_not_in_state) states = self.get_cpu_infos(all_core_subsets) - for cpu_info in states.values(): + state_values: Iterable[CPUInfo] = states.values() + for cpu_info in state_values: if cpu_info.state not in cpu_states: logger.info("x:{} y:{} p:{} state:{}", cpu_info.x, cpu_info.y, cpu_info.p, cpu_info.state)