Skip to content

Commit

Permalink
fix merge and types
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Sep 26, 2023
1 parent cb7cdcc commit bc840a5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
24 changes: 21 additions & 3 deletions spinnman/spalloc/spalloc_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]:
Expand All @@ -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(
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -127,6 +135,7 @@ def create_transceiver(self) -> Transceiver:
:rtype: Transceiver
"""
raise NotImplementedError()

@abstractmethod
def wait_for_state_change(self, old_state: SpallocState) -> SpallocState:
Expand All @@ -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):
Expand All @@ -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"):
Expand All @@ -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(
Expand All @@ -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.
Expand All @@ -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]:
Expand All @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion spinnman/transceiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bc840a5

Please sign in to comment.