spinnman.spalloc package

Submodules

spinnman.spalloc.proxy_protocol module

class spinnman.spalloc.proxy_protocol.ProxyProtocol(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

Websocket binary frame type identifiers in the Spalloc Proxy protocol.

CLOSE = 1

Message relating to closing a channel

ERROR = 5

Message relating to an error when opening or closing a channel

MSG = 2

Message sent on a channel

MSG_TO = 4

Message sent on an unbound channel to a given board

OPEN = 0

Message relating to opening a channel

OPEN_UNBOUND = 3

Message relating to opening an unbound listen-only channel

spinnman.spalloc.session module

class spinnman.spalloc.session.Session(service_url: str, username: str | None = None, password: str | None = None, token: str | None = None, session_credentials: Tuple[Dict[str, str], Dict[str, str]] | None = None)[source]

Bases: object

Manages session credentials for the Spalloc client.

Warning

This class does not present a stable API for public consumption.

Parameters:
  • service_url (str) – The reference to the service. Should not include a username or password in it.

  • username (str) – The user name to use

  • password (str) – The password to use

  • token (str) – The bearer token to use

delete(url: str, timeout: int = 10, **kwargs) Response[source]

Do an HTTP DELETE in the session.

Parameters:

url (str)

Return type:

Response

Raises:

ValueError – If the server rejects a request

get(url: str, timeout: int = 10, **kwargs) Response[source]

Do an HTTP GET in the session.

Parameters:
Return type:

Response

Raises:

ValueError – If the server rejects a request

post(url: str, json_dict: dict, timeout: int = 10, **kwargs) Response[source]

Do an HTTP POST in the session.

Parameters:
Return type:

Response

Raises:

ValueError – If the server rejects a request

put(url: str, data: str, timeout: int = 10, **kwargs) Response[source]

Do an HTTP PUT in the session. Puts plain text OR JSON!

Parameters:
Return type:

Response

Raises:

ValueError – If the server rejects a request

renew() Dict[str, int | float | str | None | JsonObject | JsonArray][source]

Renews the session, logging the user into it so that state modification operations can be performed.

Returns:

Description of the root of the service, without CSRF data

Return type:

dict

Raises:

SpallocException – If the session cannot be renewed.

websocket(url: str, header: dict | None = None, cookie: str | None = None, **kwargs) WebSocket[source]

Create a websocket that uses the session credentials to establish itself.

Parameters:
  • url (str) – Actual location to open websocket at

  • header (dict(str,str)) – Optional HTTP headers

  • cookie (str) – Optional cookies (composed as semicolon-separated string)

  • kwargs – Other options to create_connection()

Return type:

WebSocket

class spinnman.spalloc.session.SessionAware(session: Session, url: str)[source]

Bases: object

Connects to the session.

Warning

This class does not present a stable API for public consumption.

spinnman.spalloc.spalloc_boot_connection module

API of the client for the Spalloc web service.

class spinnman.spalloc.spalloc_boot_connection.SpallocBootConnection(remote_host: str | None = None)[source]

Bases: BootConnection, SpallocProxiedConnection, Listenable[SpinnakerBootMessage]

The socket interface supported by proxied boot sockets. The socket will always be talking to the root board of a job. This emulates a BootConnection.

Parameters:

remote_host (str) – The remote host name or IP address to send packets to. If not specified, the socket will be available for listening only, and will throw and exception if used for sending

Raises:

SpinnmanIOException – If there is an error setting up the communication channel

get_receive_method() Callable[[], SpinnakerBootMessage][source]

Get the method that receives for this connection.

receive_boot_message(timeout: float | None = None) SpinnakerBootMessage[source]

Receives a boot message from this connection. Blocks until a message has been received, or a timeout occurs.

Parameters:

timeout (float) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed.

Returns:

a boot message

Return type:

SpinnakerBootMessage

Raises:
send_boot_message(boot_message: SpinnakerBootMessage)[source]

Sends a SpiNNaker boot message using this connection.

Parameters:

boot_message (SpinnakerBootMessage) – The message to be sent

Raises:

SpinnmanIOException – If there is an error sending the message

spinnman.spalloc.spalloc_scp_connection module

class spinnman.spalloc.spalloc_scp_connection.SpallocSCPConnection(x, y)[source]

Bases: SCAMPConnection, SpallocProxiedConnection

The socket interface supported by proxied sockets. The socket will always be talking to a specific board. This emulates a SCAMPConnection.

Parameters:
  • chip_x (int) – The x-coordinate of the chip on the board with this remote_host

  • chip_y (int) – The y-coordinate of the chip on the board with this remote_host

  • local_host (str) – The optional IP address or host name of the local interface to listen on

  • local_port (int) – The optional local port to listen on

  • remote_host (str) – The optional remote host name or IP address to send messages to. If not specified, sending will not be possible using this connection

  • remote_port (int) – The optional remote port number to send messages to. If not specified, sending will not be possible using this connection

get_scp_data(scp_request: AbstractSCPRequest, x: int | None = None, y: int | None = None) bytes[source]

Returns the data of an SCP request as it would be sent down this connection.

Parameters:
  • x (int) – Optional: x-coordinate of where to send to

  • y (int) – Optional: y-coordinate of where to send to

receive_scp_response(timeout: float | None = 1.0) Tuple[SCPResult, int, bytes, int][source]

Receives an SCP response from this connection. Blocks until a message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if None, will wait forever, or until the connection is closed

Returns:

The SCP result, the sequence number, the data of the response and the offset at which the data starts (i.e., where the SDP header starts).

Return type:

tuple(SCPResult, int, bytes, int)

Raises:
receive_sdp_message(timeout: float | None = None) SDPMessage[source]

Receives an SDP message from this connection. Blocks until the message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed.

Returns:

The received SDP message

Return type:

SDPMessage

Raises:
send_sdp_message(sdp_message: SDPMessage)[source]

Sends an SDP message down this connection.

Parameters:

sdp_message (SDPMessage) – The SDP message to be sent

Raises:

SpinnmanIOException – If there is an error sending the message.

Module contents

The new Spalloc client implementation. This has the notable distinction of including a proxying system that allows creating a transceiver with access to the boards of a job despite the client being not within the same firewall/NAT security domain as the Spalloc-managed service.

The main class in here is SpallocClient.

class spinnman.spalloc.AbstractSpallocClient

Bases: object

The API exported by the Spalloc Client.

abstract create_job(num_boards: int = 1, machine_name: str | None = None, keepalive: int = 45) SpallocJob[source]

Create a job with a specified number of boards.

Parameters:
  • num_boards (int) – How many boards to ask for (defaults to 1)

  • machine_name (str) – Which machine to run on? If omitted, the service’s machine tagged with default will be used.

  • keepalive (int) – After how many seconds of no activity should a job become eligible for automatic pruning?

Returns:

A handle for monitoring and interacting with the job.

Return type:

SpallocJob

abstract create_job_board(triad: Tuple[int, int, int] | None = None, physical: Tuple[int, int, int] | None = None, ip_address: str | None = None, machine_name: str | None = None, keepalive: int = 45) SpallocJob[source]

Create a job with a specific board. At least one of triad, physical and ip_address must be not None.

Parameters:
  • triad (tuple(int,int,int)) – The logical coordinate of the board to request

  • physical (tuple(int,int,int)) – The physical coordinate of the board to request

  • ip_address (str) – The IP address of the board to request

  • machine_name (str) – Which machine to run on? If omitted, the service’s machine tagged with default will be used.

  • keepalive (int) – After how many seconds of no activity should a job become eligible for automatic pruning?

Returns:

A handle for monitoring and interacting with the job.

Return type:

SpallocJob

abstract create_job_rect(width: int, height: int, machine_name: str | None = None, keepalive: int = 45) SpallocJob[source]

Create a job with a rectangle of boards.

Parameters:
  • width (int) – The width of rectangle to request

  • height (int) – The height of rectangle to request

  • machine_name (str) – Which machine to run on? If omitted, the service’s machine tagged with default will be used.

  • keepalive (int) – After how many seconds of no activity should a job become eligible for automatic pruning?

Returns:

A handle for monitoring and interacting with the job.

Return type:

SpallocJob

abstract create_job_rect_at_board(width: int, height: int, triad: Tuple[int, int, int] | None = None, physical: Tuple[int, int, int] | None = None, ip_address: str | None = None, machine_name: str | None = None, keepalive: int = 45, max_dead_boards: int = 0) SpallocJob[source]

Create a job with a rectangle of boards starting at a specific board. At least one of triad, physical and ip_address must be not None.

Parameters:
  • width (int) – The width of rectangle to request

  • height (int) – The height of rectangle to request

  • triad (tuple(int,int,int)) – The logical coordinate of the board to request

  • physical (tuple(int,int,int)) – The physical coordinate of the board to request

  • ip_address (str) – The IP address of the board to request

  • machine_name (str) – Which machine to run on? If omitted, the service’s machine tagged with default will be used.

  • keepalive (int) – After how many seconds of no activity should a job become eligible for automatic pruning?

  • max_dead_boards (int) – How many dead boards can be included.

Returns:

A handle for monitoring and interacting with the job.

Return type:

SpallocJob

abstract list_jobs(deleted: bool = False) Iterable[SpallocJob][source]

Get the jobs known to the server.

Parameters:

deleted (bool) – Whether to include deleted jobs.

Returns:

The jobs known to the server.

Return type:

Iterable(SpallocJob)

abstract list_machines() Dict[str, SpallocMachine][source]

Get the machines supported by the server.

Returns:

Mapping from machine names to handles for working with a machine.

Return type:

dict(str,SpallocMachine)

class spinnman.spalloc.SpallocClient(service_url: str, username: str | None = None, password: str | None = None, bearer_token: str | None = None, group: str | None = None, collab: str | None = None, nmpi_job: int | None = None, nmpi_user: str | None = None)

Bases: AbstractContextManager, AbstractSpallocClient

Basic client library for talking to new Spalloc.

Parameters:
  • service_url (str) – The reference to the service. May have username and password supplied as part of the network location; if so, the username and password arguments must be None. If username and password are not given, not even within the URL, the bearer_token must be not None.

  • username (str) – The user name to use

  • password (str) – The password to use

  • bearer_token (str) – The bearer token to use

close() None[source]

How to actually close the underlying resources.

create_job(num_boards: int = 1, machine_name: str | None = None, keepalive: int = 45) SpallocJob[source]

Create a job with a specified number of boards.

Parameters:
  • num_boards (int) – How many boards to ask for (defaults to 1)

  • machine_name (str) – Which machine to run on? If omitted, the service’s machine tagged with default will be used.

  • keepalive (int) – After how many seconds of no activity should a job become eligible for automatic pruning?

Returns:

A handle for monitoring and interacting with the job.

Return type:

SpallocJob

create_job_board(triad: Tuple[int, int, int] | None = None, physical: Tuple[int, int, int] | None = None, ip_address: str | None = None, machine_name: str | None = None, keepalive: int = 45) SpallocJob[source]

Create a job with a specific board. At least one of triad, physical and ip_address must be not None.

Parameters:
  • triad (tuple(int,int,int)) – The logical coordinate of the board to request

  • physical (tuple(int,int,int)) – The physical coordinate of the board to request

  • ip_address (str) – The IP address of the board to request

  • machine_name (str) – Which machine to run on? If omitted, the service’s machine tagged with default will be used.

  • keepalive (int) – After how many seconds of no activity should a job become eligible for automatic pruning?

Returns:

A handle for monitoring and interacting with the job.

Return type:

SpallocJob

create_job_rect(width: int, height: int, machine_name: str | None = None, keepalive: int = 45) SpallocJob[source]

Create a job with a rectangle of boards.

Parameters:
  • width (int) – The width of rectangle to request

  • height (int) – The height of rectangle to request

  • machine_name (str) – Which machine to run on? If omitted, the service’s machine tagged with default will be used.

  • keepalive (int) – After how many seconds of no activity should a job become eligible for automatic pruning?

Returns:

A handle for monitoring and interacting with the job.

Return type:

SpallocJob

create_job_rect_at_board(width: int, height: int, triad: Tuple[int, int, int] | None = None, physical: Tuple[int, int, int] | None = None, ip_address: str | None = None, machine_name: str | None = None, keepalive: int = 45, max_dead_boards: int = 0) SpallocJob[source]

Create a job with a rectangle of boards starting at a specific board. At least one of triad, physical and ip_address must be not None.

Parameters:
  • width (int) – The width of rectangle to request

  • height (int) – The height of rectangle to request

  • triad (tuple(int,int,int)) – The logical coordinate of the board to request

  • physical (tuple(int,int,int)) – The physical coordinate of the board to request

  • ip_address (str) – The IP address of the board to request

  • machine_name (str) – Which machine to run on? If omitted, the service’s machine tagged with default will be used.

  • keepalive (int) – After how many seconds of no activity should a job become eligible for automatic pruning?

  • max_dead_boards (int) – How many dead boards can be included.

Returns:

A handle for monitoring and interacting with the job.

Return type:

SpallocJob

list_jobs(deleted: bool = False) Iterable[SpallocJob][source]

Get the jobs known to the server.

Parameters:

deleted (bool) – Whether to include deleted jobs.

Returns:

The jobs known to the server.

Return type:

Iterable(SpallocJob)

list_machines() Dict[str, SpallocMachine][source]

Get the machines supported by the server.

Returns:

Mapping from machine names to handles for working with a machine.

Return type:

dict(str,SpallocMachine)

static open_job_from_database(service_url, job_url, cookies, headers) SpallocJob[source]

Create a job from the description in the attached database. This is intended to allow for access to the job’s allocated resources from visualisers and other third party code participating in the SpiNNaker Tools Notification Protocol.

Note

The job is not verified to exist and be running. The session credentials may have expired; if so, the job will be unable to regenerate them.

Parameters:
Returns:

The job handle, or None if the records in the database are absent or incomplete.

Return type:

SpallocJob

version
class spinnman.spalloc.SpallocEIEIOConnection(local_host: str | None = None, local_port: int | None = None, remote_host: str | None = None, remote_port: int | None = None)

Bases: EIEIOConnection, SpallocProxiedConnection

The socket interface supported by proxied EIEIO connected sockets. This emulates an EIEOConnection opened with a remote address specified.

Parameters:
  • local_host (str) – The local host name or IP address to bind to. If not specified defaults to bind to all interfaces, unless remote_host is specified, in which case binding is done to the IP address that will be used to send packets

  • local_port (int) – The local port to bind to, between 1025 and 65535. If not specified, defaults to a random unused local port

  • remote_host (str) – The remote host name or IP address to send packets to. If not specified, the socket will be available for listening only, and will throw and exception if used for sending

  • remote_port (int) – The remote port to send packets to. If remote_host is None, this is ignored. If remote_host is specified specified, this must also be specified for the connection to allow sending

Raises:

SpinnmanIOException – If there is an error setting up the communication channel

receive_eieio_message(timeout: float | None = None) AbstractEIEIOMessage[source]

Receives an EIEIO message from this connection. Blocks until a message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed

Returns:

an EIEIO message

Return type:

AbstractEIEIOMessage

Raises:
send_eieio_message(eieio_message: AbstractEIEIOMessage)[source]

Sends an EIEIO message down this connection.

Parameters:

eieio_message (AbstractEIEIOMessage) – The EIEIO message to be sent

Raises:

SpinnmanIOException – If there is an error sending the message

send_eieio_message_to_core(eieio_message: AbstractEIEIOMessage, x: int, y: int, p: int)[source]
Parameters:
Return type:

None

update_tag(tag: int, do_receive: bool = True)[source]

Update the given tag on the connected Ethernet-enabled chip to send messages to this connection.

Parameters:
  • tag (int) – The tag ID to update

  • do_receive (bool) – Whether to do the reception of the response or not

Raises:
class spinnman.spalloc.SpallocEIEIOListener(local_host: str | None = None, local_port: int | None = None, remote_host: str | None = None, remote_port: int | None = None)

Bases: EIEIOConnection, SpallocProxiedConnection

The socket interface supported by proxied EIEIO listener sockets. This emulates an EIEOConnection opened with no address specified.

Parameters:
  • local_host (str) – The local host name or IP address to bind to. If not specified defaults to bind to all interfaces, unless remote_host is specified, in which case binding is done to the IP address that will be used to send packets

  • local_port (int) – The local port to bind to, between 1025 and 65535. If not specified, defaults to a random unused local port

  • remote_host (str) – The remote host name or IP address to send packets to. If not specified, the socket will be available for listening only, and will throw and exception if used for sending

  • remote_port (int) – The remote port to send packets to. If remote_host is None, this is ignored. If remote_host is specified specified, this must also be specified for the connection to allow sending

Raises:

SpinnmanIOException – If there is an error setting up the communication channel

abstract property local_ip_address: str

The IP address on the server to which the connection is bound.

Returns:

The IP address as a dotted string, e.g., 0.0.0.0

Return type:

str

abstract property local_port: int

The port on the server to which the connection is bound.

Returns:

The local port number

Return type:

int

receive_eieio_message(timeout: float | None = None) AbstractEIEIOMessage[source]

Receives an EIEIO message from this connection. Blocks until a message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed

Returns:

an EIEIO message

Return type:

AbstractEIEIOMessage

Raises:
send(data: bytes)[source]

Send a message on an open socket.

Parameters:

data – The message to send.

Note

This class does not allow sending.

send_eieio_message_to_core(eieio_message: AbstractEIEIOMessage, x: int, y: int, p: int, ip_address: str)[source]

Send an EIEIO message (one way) to a given core.

Parameters:
  • eieio_message (AbstractEIEIOMessage) – The message to send.

  • x (int) – The X coordinate of the core to send to.

  • y (int) – The Y coordinate of the core to send to.

  • p (int) – The ID of the core to send to.

  • ip_address (str) – The IP address of the Ethernet-enabled chip to route the message via.

send_to(data: bytes, address: Tuple[str, int])[source]

Send a message on an open socket.

Parameters:
  • message (bytes) – The message to send.

  • address (tuple(str,int)) – Where to send it to. Must be the address of an Ethernet-enabled chip on a board allocated to the job. Does not mean that SpiNNaker is listening on that port (but the SCP port is being listened to if the board is booted).

abstract send_to_chip(message: bytes, x: int, y: int, port: int = 17893)[source]

Send a message on an open socket to a particular board.

Parameters:
  • message (bytes) – The message to send.

  • x (int) – The X coordinate of the Ethernet-enabled chip to send the message to.

  • y (int) – The Y coordinate of the Ethernet-enabled chip to send the message to.

  • port (int) – The UDP port on the Ethernet-enabled chip to send the message to. Defaults to the SCP port.

update_tag(x: int, y: int, tag: int, do_receive: bool = True)[source]

Update the given tag on the given Ethernet-enabled chip to send messages to this connection.

Parameters:
  • x (int) – The Ethernet-enabled chip’s X coordinate

  • y (int) – The Ethernet-enabled chip’s Y coordinate

  • tag (int) – The tag ID to update

  • do_receive (bool) – Whether to receive the response or not

Raises:
update_tag_by_ip(ip_address: str, tag: int)[source]

Update a tag on a board at a given IP address to send messages to this connection.

Parameters:
  • ip_address (str) – The address of the Ethernet-enabled chip

  • tag (int) – The ID of the tag

class spinnman.spalloc.SpallocJob

Bases: object

Represents a job in Spalloc.

Don’t make this yourself. Use SpallocClient instead.

abstract connect_for_booting() SpallocBootConnection[source]

Open a connection to a job’s allocation so it can be booted.

Returns:

a boot connection

Return type:

SpallocBootConnection

abstract connect_to_board(x: int, y: int, port: int = 17893) SpallocSCPConnection[source]

Open a connection to a particular board in the job.

Parameters:
  • x (int) – X coordinate of the board’s Ethernet-enabled chip

  • y (int) – Y coordinate of the board’s Ethernet-enabled chip

  • port (int) – UDP port to talk to; defaults to the SCP port

Returns:

A connection that talks to the board.

Return type:

SpallocProxiedConnection

abstract create_transceiver() Transceiver[source]

Create a transceiver that will talk to this job. The transceiver will only be configured to talk to the SCP ports of the boards of the job.

Return type:

Transceiver

abstract destroy(reason: str = 'finished')[source]

Destroy the job.

Parameters:

reason (str) – Why the job is being destroyed.

abstract get_connections() Dict[Tuple[int, int], str][source]

Get the mapping from board coordinates to IP addresses.

Returns:

(x,y)->IP mapping, or None if not allocated

Return type:

dict(tuple(int,int), str) or None

abstract get_root_host() str | None[source]

Get the IP address for talking to the machine.

Returns:

The IP address, or None if not allocated.

Return type:

str or None

abstract get_session_credentials_for_db() Mapping[Tuple[str, str], str][source]

Get the session credentials for the job to be written into a database

Note

May assume that there is a proxy_configuration table with kind, name and value columns.

abstract get_state(wait_for_change: bool = False) SpallocState[source]

Get the current state of the machine.

Parameters:

wait_for_change (bool) – Whether to wait for a change in state

Return type:

SpallocState

abstract keepalive() None[source]

Signal the job that we want it to stay alive for a while longer.

abstract launch_keepalive_task(period: int = 30) AbstractContextManager[source]

Starts a periodic task to keep a job alive.

Parameters:
  • job (SpallocJob) – The job to keep alive

  • period (int) – How often to send a keepalive message (in seconds)

Returns:

Some kind of closeable task handle; closing it terminates the task. Destroying the job will also terminate the task.

abstract open_eieio_connection(x: int, y: int) SpallocEIEIOConnection[source]

Open an EIEIO connection to a specific board in a job.

Parameters:
  • x (int) – The X coordinate of the Ethernet-enabled chip to connect to

  • y (int) – The Y coordinate of the Ethernet-enabled chip to connect to

Returns:

an EIEIO connection with a board address bound

Return type:

SpallocEIEIOConnection

abstract open_eieio_listener_connection() SpallocEIEIOListener[source]

Open a listening EIEIO connection to the job’s boards. Messages cannot be sent on this connection unless you say which board to send to, but they can be received from all boards. You can also get the server side connection information so you can program that into a tag.

Returns:

an EIEIO connection with no board address bound

Return type:

SpallocEIEIOListener

abstract open_udp_listener_connection() UDPConnection[source]

Open a listening UDP connection to the job’s boards. Messages cannot be sent on this connection unless you say which board to send to, but they can be received from all boards. You can also get the server side connection information so you can program that into a tag.

Returns:

a UDP connection with no board address bound

Return type:

UDPConnection

abstract wait_for_state_change(old_state: SpallocState, timeout: int | None = None) SpallocState[source]

Wait until the allocation is not in the given old state.

Parameters:
  • old_state (SpallocState) – The state that we are looking to change out of.

  • timeout (int or None) – The time to wait, or None to wait forever

Returns:

The state that the allocation is now in.

Note

If the machine gets destroyed, this will not wait for it.

Return type:

SpallocState

abstract wait_until_ready(timeout: int | None = None, n_retries: int | None = None)[source]

Wait until the allocation is in the READY state.

Parameters:
  • timeout (int or None) – The timeout or None to wait forever

  • n_retries (int or None) – The number of times to retry, or None to retry forever

Raises:

Exception – If the allocation is destroyed

abstract where_is_machine(x: int, y: int) Tuple[int, int, int] | None[source]

Get the physical coordinates of the board hosting the given chip.

Parameters:
  • x (int) – Chip X coordinate

  • y (int) – Chip Y coordinate

Returns:

physical board coordinates (cabinet, frame, board), or None if there are no boards currently allocated to the job or the chip lies outside the allocation.

Return type:

tuple(int,int,int) or None

class spinnman.spalloc.SpallocMachine

Bases: object

Represents a Spalloc-controlled machine.

Don’t make this yourself. Use SpallocClient instead.

abstract property area: Tuple[int, int]

Area of machine, in boards.

Returns:

width, height

Return type:

tuple(int,int)

abstract property dead_boards: list

The dead or out-of-service boards of the machine.

The dead or out-of-service links of the machine.

abstract property height: int

The height of the machine, in boards.

abstract property name: str

The name of the machine.

abstract property tags: FrozenSet[str]

The tags of the machine.

abstract property width: int

The width of the machine, in boards.

class spinnman.spalloc.SpallocProxiedConnection

Bases: Listenable

Base class for connections proxied via Spalloc.

abstract receive(timeout: float | None = None) bytes[source]

Receive a message on an open socket. Will block until a message is received.

Parameters:

timeout (int or float or None) – How long to wait for a message to be received before timing out. If None, will wait indefinitely (or until the connection is closed).

Returns:

The received message.

Raises:

SpinnmanTimeoutException – If a timeout happens

abstract send(data: bytes)[source]

Send a message on an open socket.

Parameters:

data – The message to send.

class spinnman.spalloc.SpallocState(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: IntEnum

The possible states of a Spalloc Job.

Jobs start as QUEUED, then move to POWER once they’ve been allocated. Once the job’s boards have been switched on and the hardware stabilised, the job moves to state READY. (It goes back to POWER if you tell it to switch off or on; this is not recommended.) Finally, it goes to DESTROYED once the job is completed in any way.

The UNKNOWN state is used when something odd is going on. It should normally be ignored.

DESTROYED = 4
POWER = 2
QUEUED = 1
READY = 3
UNKNOWN = 0
spinnman.spalloc.is_server_address(address: str, additional_schemes: Iterable[str] = ()) bool

Test if the given address is a likely Spalloc server URL.

Parameters:
  • address (str) – The address to check

  • additional_schemes (Iterable(str)) – Any additional URL schemes that should be considered to be successes; typically {"spalloc"} when looser matching is required.

Return type:

bool