spinnman.spalloc package

Submodules

spinnman.spalloc.proxy_protocol module

class spinnman.spalloc.proxy_protocol.ProxyProtocol(value)[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 – The reference to the service. Should not include a username or password in it.

  • username – The user name to use

  • password – The password to use

  • token – The bearer token to use

property credentials: Tuple[Dict[str, str], Dict[str, str]]

The credentials for requests. Serializable.

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

Do an HTTP DELETE in the session.

Parameters:
  • url

  • timeout – Time to wait for the call to return

  • kwargs – Optional extra parameters to send with the request

Returns:

The response verified that it is not an error

Raises:

ValueError – If the server rejects a request

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

Do an HTTP GET in the session.

Parameters:
  • url

  • timeout – Time to wait for the call to return

  • kwargs – Optional extra parameters to send with the request

Returns:

The response verified that it is not an error

Raises:

ValueError – If the server rejects a request

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

Do an HTTP POST in the session.

Parameters:
  • url

  • json_dict

  • timeout – Time to wait for the call to return

  • kwargs – Optional extra parameters to send with the request

Returns:

The response verified that it is not an error

Raises:

ValueError – If the server rejects a request

post_raw(url: str, data: bytes, timeout: int = 10, **kwargs: Any) Response | None[source]

Do an HTTP POST in the session. Posts raw data!

Parameters:
  • url

  • data

  • timeout – Time to wait for the call to return

  • kwargs – Optional extra parameters to send with the request

Returns:

The response verified that it is not an error

Raises:

ValueError – If the server rejects a request

purge() None[source]

Clears out all credentials from this session, rendering the session completely inoperable henceforth.

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

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

Parameters:
  • url

  • data

  • timeout – Time to wait for the call to return

  • kwargs – Optional extra parameters to send with the request

Returns:

The response verified that it is not an error

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

Raises:

SpallocException – If the session cannot be renewed.

property service_url: str

Get the service URL for this session.

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

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

Parameters:
  • url – Actual location to open websocket at

  • header – Optional HTTP headers

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

  • kwargs – Other options to create_connection()

Returns:

Socket based on these credentials

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.

Parameters:
  • session – The session created when starting the spalloc client

  • url – job_url

spinnman.spalloc.spalloc_allocator module

class spinnman.spalloc.spalloc_allocator.SpallocJobController(client: SpallocClient, job: SpallocJob, use_proxy: bool)[source]

Bases: MachineAllocationController

A class to Create and support Transceivers specific for Spalloc.

Parameters:
  • client

  • job

  • use_proxy

can_create_transceiver() bool[source]
Returns:

True if create_transceiver would work

close() None[source]

Indicate that the use of the machine is complete.

create_transceiver(ensure_board_is_ready: bool) Transceiver[source]

Create a Transceiver using proxy

Note

This allocation controller proxies the transceiver’s connections via Spalloc. This allows it to work even outside the UNIMAN firewall.

Parameters:

ensure_board_is_ready – Flag to say if ensure_board_is_ready should be run

Returns:

A proxied Transceiver

extend_allocation(new_total_run_time: float) None[source]

Extend the allocation of the machine from the original run time.

Parameters:

new_total_run_time – The total run time that is now required starting from when the machine was first allocated

property job: SpallocJob

The job value passed into the init.

open_sdp_connection(chip_x: int, chip_y: int, udp_port: int = 17893) SCAMPConnection | None[source]

Open a connection to a specific Ethernet-enabled SpiNNaker chip. Caller will have to arrange for SpiNNaker to pay attention to the connection. The coordinates will be job-relative. .. note:

This allocation controller proxies connections via Spalloc. This
allows it to work even outside the UNIMAN firewall.
Parameters:
  • chip_x – Ethernet-enabled chip X coordinate

  • chip_y – Ethernet-enabled chip Y coordinate

  • udp_port – the UDP port on the chip to connect to; connecting to a non-SCP port will result in a connection that can’t easily be configured.

Returns:

Connection to the Chip with a know host over this port or None

property proxying: bool

Whether this is a proxying connection. False unless overridden.

where_is_machine(chip_x: int, chip_y: int) Tuple[int, int, int][source]

Locates and returns cabinet, frame, board for a given chip in a machine allocated to this job.

Parameters:
  • chip_x – chip x location

  • chip_y – chip y location

Returns:

(cabinet, frame, board)

spinnman.spalloc.spalloc_allocator.spalloc_allocate_job() Tuple[str, Dict[Tuple[int, int], str], SpallocJobController][source]

Request a machine from an new-style spalloc server that will fit the given number of boards.

Returns:

host, board address map, allocation controller

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 – 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]
Returns:

The method that receives 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 – 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

Raises:
send_boot_message(boot_message: SpinnakerBootMessage) None[source]

Sends a SpiNNaker boot message using this connection.

Parameters:

boot_message – 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: int, y: int)[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:
  • x – The x-coordinate of the chip on the board with this remote_host

  • y – The y-coordinate of the chip on the board with this remote_host

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 – Optional: x-coordinate of where to send to

  • y – 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 – 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).

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 – 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

Raises:
send_sdp_message(sdp_message: SDPMessage) None[source]

Sends an SDP message down this connection.

Parameters:

sdp_message – The SDP message to be sent

Raises:

SpinnmanIOException – If there is an error sending the message.

spinnman.spalloc.spalloc_transceiver module

class spinnman.spalloc.spalloc_transceiver.SpallocTransceiver(job: SpallocJob, ensure_board_is_ready: bool = False)[source]

Bases: Version5Transceiver

A transceiver for a Spalloc job, where some functions use spalloc more directly to speed up operation.

Create a Spalloc Transceiver.

Parameters:
  • job – The job to use to communicate with the machine via Spalloc

  • ensure_board_is_ready – Flag to say if ensure_board_is_ready should be run

read_memory(x: int, y: int, base_address: int, length: int, cpu: int = 0) bytearray[source]

Read some areas of memory (usually SDRAM) from the board.

Parameters:
  • x – The x-coordinate of the chip where the memory is to be read from

  • y – The y-coordinate of the chip where the memory is to be read from

  • base_address – The address in SDRAM where the region of memory to be read starts

  • length – The length of the data to be read in bytes

  • cpu – the core ID used to read the memory of; should usually be 0 when reading from SDRAM, but may be other values when reading from DTCM.

Returns:

A bytearray of data read

Raises:
write_memory(x: int, y: int, base_address: int, data: BinaryIO | bytes | int | str, *, n_bytes: int | None = None, offset: int = 0, cpu: int = 0, get_sum: bool = False) Tuple[int, int][source]

Write to the SDRAM on the board.

Parameters:
  • x – The x-coordinate of the chip where the memory is to be written to

  • y – The y-coordinate of the chip where the memory is to be written to

  • base_address – The address in SDRAM where the region of memory is to be written

  • data

    The data to write. Should be one of the following:

    • An instance of RawIOBase

    • A bytearray/bytes

    • A single integer - will be written in little-endian byte order

    • A string - the filename of a data file

  • n_bytes

    The amount of data to be written in bytes. If not specified:

    • If data is an RawIOBase, an error is raised

    • If data is a bytearray, the length of the bytearray will be used

    • If data is an int, 4 will be used

    • If data is a str, the length of the file will be used

  • offset – The offset from which the valid data begins

  • cpu – The optional CPU to write to

  • get_sum – whether to return a checksum or 0

Returns:

The number of bytes written, the checksum (0 if get_sum=False)

Raises:

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.

abstractmethod create_job() SpallocJob[source]

Create a job with a specified number of boards.

Returns:

A handle for monitoring and interacting with the job.

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

Get the jobs known to the server.

Parameters:

deleted – Whether to include deleted jobs.

Returns:

The jobs known to the server.

abstractmethod 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.

class spinnman.spalloc.MachineAllocationController(thread_name: str)

Bases: object

How to manage the allocation of a machine so that it gets cleaned up neatly when the script dies.

Parameters:

thread_name

close() None[source]

Indicate that the use of the machine is complete.

abstractmethod extend_allocation(new_total_run_time: float) None[source]

Extend the allocation of the machine from the original run time.

Parameters:

new_total_run_time – The total run time that is now required starting from when the machine was first allocated

property proxying: bool

Whether this is a proxying connection. False unless overridden.

abstractmethod where_is_machine(chip_x: int, chip_y: int) Tuple[int, int, int][source]

Locates and returns cabinet, frame, board for a given chip in a machine allocated to this job.

Parameters:
  • chip_x – chip x location

  • chip_y – chip y location

Returns:

(cabinet, frame, board)

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 – 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 – The user name to use. If not provided nor in service_url environment variable SPALLOC_USER will be used.

  • password – The password to use. If not provided nor in service_url environment variable SPALLOC_PASSWORD will be used.

  • bearer_token – The bearer token to use

close() None[source]

How to actually close the underlying resources.

create_job() SpallocJob[source]

Create a job with a specified number of boards.

Returns:

A handle for monitoring and interacting with the job.

get_job(job_id: str) SpallocJob[source]

Get a job by its job id.

Parameters:

job_id – The job id.

Returns:

Job object for this ID

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

Get the jobs known to the server.

Parameters:

deleted – Whether to include deleted jobs.

Returns:

The jobs known to the server.

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.

static open_job_from_database(service_url: str, job_url: str, cookies: Dict[str, str], headers: Dict[str, str]) 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:
  • service_url

  • job_url

  • cookies

  • headers

Returns:

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

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 – 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 – The local port to bind to, between 1025 and 65535. If not specified, defaults to a random unused local port

  • remote_host – 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 – 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 – 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

Raises:
send_eieio_message(eieio_message: AbstractEIEIOMessage) None[source]

Sends an EIEIO message down this connection.

Parameters:

eieio_message – 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) None[source]

Sends the message including a header

Parameters:
  • eieio_message – Message to send

  • x – destination chip x

  • y – destination chip y

  • p – destination_cpu

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

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

Parameters:
  • tag – The tag ID to update

  • do_receive – 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 – 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 – The local port to bind to, between 1025 and 65535. If not specified, defaults to a random unused local port

  • remote_host – 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 – 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.

abstract property local_port: int

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

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 – 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

Raises:
send(data: bytes) None[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) None[source]

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

Parameters:
  • eieio_message – The message to send.

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

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

  • p – The ID of the core to send to.

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

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

Send a message on an open socket.

Parameters:
  • data – The message to send.

  • address – 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).

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

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

Parameters:
  • message – The message to send.

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

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

  • port – 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) None[source]

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

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

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

  • tag – The tag ID to update

  • do_receive – Whether to receive the response or not

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

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

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

  • tag – The ID of the tag

class spinnman.spalloc.SpallocJob

Bases: AbstractContextManager

Represents a job in Spalloc.

Don’t make this yourself. Use SpallocClient instead.

abstractmethod connect_for_booting() SpallocBootConnection[source]

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

Returns:

a boot connection

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

Open a connection to a particular board in the job.

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

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

  • port – UDP port to talk to; defaults to the SCP port

Returns:

A connection that talks to the board.

abstractmethod create_transceiver(ensure_board_is_ready: bool = True) 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.

Parameters:

ensure_board_is_ready – Flag to say if ensure_board_is_ready should be run

Returns:

Transceiver that uses this job.

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

Destroy the job.

Parameters:

reason – Why the job is being destroyed.

abstractmethod 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

abstractmethod get_root_host() str | None[source]

Get the IP address for talking to the machine.

Returns:

The IP address, or None if not allocated.

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

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

These are the “COOKIE” “HEADER” items, .. note:

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

Mapping of Tuple[“COOKIE” or “HEADER”, and the key] to the value for that key

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

Get the current state of the machine.

Parameters:

wait_for_change – Whether to wait for a change in state

Returns:

The current or new state

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

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

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

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

Returns:

an EIEIO connection with a board address bound

abstractmethod 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

abstractmethod 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

abstractmethod read_data(x: int, y: int, address: int, size: int) bytes[source]

Write data to a given address on a given chip of the job.

Parameters:
  • x – The X coordinate of the chip

  • y – The Y coordinate of the chip

  • address – The address to write to

  • size – The number of bytes to read

Returns:

The data read

abstractmethod reset_routing(custom_filters: Dict[int, DiagnosticFilter]) None[source]

Clear the routes, reset diagnostic counters and optionally set filters.

Parameters:

custom_filters – Map of router filter id to filter to set.

abstractmethod 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 – The state that we are looking to change out of.

  • timeout – 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.

abstractmethod wait_until_ready() None[source]

Wait until the allocation is in the READY state.

Raises:
  • SpallocException – If the allocation is destroyed

  • SSpallocBoardUnavailableException – If a job for specific boards are disabled, in use or just wrong

abstractmethod 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 – Chip X coordinate

  • y – 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.

abstractmethod write_data(x: int, y: int, address: int, data: bytes) None[source]

Write data to a given address on a given chip of the job.

Parameters:
  • x – The X coordinate of the chip

  • y – The Y coordinate of the chip

  • address – The address to write to

  • data – The data to write

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]

The width and height of machine

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.

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

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

Parameters:

timeout – 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

abstractmethod send(data: bytes) None[source]

Send a message on an open socket.

Parameters:

data – The message to send.

class spinnman.spalloc.SpallocState(value)

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 – The address to check

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

Returns:

True if the address matches a pattern that could be a server..