spinn_front_end_common.utilities.database package

Module contents

class spinn_front_end_common.utilities.database.DatabaseConnection(start_resume_callback_function: Callable[[], None] | None = None, stop_pause_callback_function: Callable[[], None] | None = None, local_host: str | None = None, local_port: int | None = 19999)

Bases: UDPConnection

A connection from the toolchain which will be notified when the database has been written, and can then respond when the database has been read, and further wait for notification that the simulation has started.

Note

The machine description database reader can only be used while the registered database callbacks are running.

Note

This class coordinates with the NotificationProtocol class without routing messages via SpiNNaker.

Parameters:
  • start_resume_callback_function (callable) – A function to be called when the start message has been received. This function should not take any parameters or return anything.

  • local_host (str) – Optional specification of the local hostname or IP address of the interface to listen on

  • local_port (int) – Optional specification of the local port to listen on. Must match the port that the toolchain will send the notification on (19999 by default)

add_database_callback(database_callback_function: Callable[[DatabaseReader], None])[source]

Add a database callback to be called when the database is ready.

Parameters:

database_callback_function (callable(DatabaseReader,None)) – A function to be called when the database message has been received. This function should take a single parameter, which will be a DatabaseReader object. Once the function returns, it will be assumed that the database has been read and will not be needed further, and the return response will be sent.

close() None[source]

Closes the connection.

class spinn_front_end_common.utilities.database.DatabaseReader(database_path: str)

Bases: SQLiteDB

A reader for the database.

Parameters:

database_path (str) – The path to the database

get_atom_id_to_key_mapping(label: str) Dict[int, int][source]

Get a mapping of atom ID to event key for a given vertex.

Parameters:

label (str) – The label of the vertex

Returns:

dictionary of event keys indexed by atom ID

Return type:

dict(int, int)

get_configuration_parameter_value(parameter_name: str) float | None[source]

Get the value of a configuration parameter.

Parameters:

parameter_name (str) – The name of the parameter

Returns:

The value of the parameter

Return type:

float or None

get_ip_address(x: int, y: int) str | None[source]

Get an IP address to contact a chip.

Parameters:
  • x (int) – The x-coordinate of the chip

  • y (int) – The y-coordinate of the chip

Returns:

The IP address of the Ethernet to use to contact the chip

Return type:

str or None

get_job() SpallocJob | None[source]

Get the job described in the database. If no job exists, direct connection to boards should be used.

Returns:

Job handle, if one exists. None otherwise.

Return type:

SpallocJob

get_key_to_atom_id_mapping(label: str) Dict[int, int][source]

Get a mapping of event key to atom ID for a given vertex.

Parameters:

label (str) – The label of the vertex

Returns:

dictionary of atom IDs indexed by event key

Return type:

dict(int, int)

get_live_output_details(label: str, receiver_label: str) Tuple[str, int, bool, str, int, int, int][source]

Get the IP address, port and whether the SDP headers are to be stripped from the output from a vertex.

Parameters:

label (str) – The label of the vertex

Returns:

tuple of (IP address, port, strip SDP, board address, tag, chip_x, chip_y)

Return type:

tuple(str, int, bool, str, int, int, int)

get_placements(label: str) List[Tuple[int, int, int]][source]

Get the placements of an application vertex with a given label.

Parameters:

label (str) – The label of the vertex

Returns:

A list of x, y, p coordinates of the vertices

Return type:

list(tuple(int, int, int))

class spinn_front_end_common.utilities.database.DatabaseWriter

Bases: SQLiteDB

The interface for the database system for main front ends. Any special tables needed from a front end should be done by subclasses of this interface.

Parameters:
  • database_file (str) – The name of a file that contains (or will contain) an SQLite database holding the data. If omitted, an unshared in-memory database will be used (suitable only for testing).

  • read_only (bool) – Whether the database is in read-only mode. When the database is in read-only mode, it must already exist.

  • ddl_file (str or None) – The name of a file (typically containing SQL DDL commands used to create the tables) to be evaluated against the database before this object completes construction. If None, nothing will be evaluated. You probably don’t want to specify a DDL file at the same time as setting read_only=True.

  • row_factory (Callable or None) – Callable used to create the rows of result sets. Either tuple or sqlite3.Row (default); can be None to use the DB driver default.

  • text_factory (Callable or None) – Callable used to create the Python values of non-numeric columns in result sets. Usually memoryview (default) but should be str when you’re expecting string results; can be None to use the DB driver default.

  • case_insensitive_like (bool) – Whether we want the LIKE matching operator to be case-sensitive or case-insensitive (default).

  • timeout (float) – How many seconds the connection should wait before raising an OperationalError when a table is locked. If another connection opens a transaction to modify a table, that table will be locked until the transaction is committed. Default five seconds.

  • synchronisation (Synchronisation) – The synchronisation level. Doesn’t normally need to be altered.

add_application_vertices() None[source]

Stores the main application graph description (vertices, edges).

add_lpg_mapping() List[Tuple[MachineVertex, str]][source]

Add mapping from machine vertex to LPG machine vertex.

Returns:

A list of (source vertex, partition id)

Return type:

list(MachineVertex, str)

add_machine_objects() None[source]

Store the machine object into the database.

add_placements() None[source]

Adds the placements objects into the database.

add_proxy_configuration() None[source]

Store the proxy configuration.

add_system_params(runtime: float | None)[source]

Write system parameters into the database.

Parameters:

runtime (int) – the amount of time the application is to run for

add_tags() None[source]

Adds the tags into the database.

static auto_detect_database() bool[source]

Auto detects if there is a need to activate the database system.

Returns:

whether the database is needed for the application

Return type:

bool

create_atom_to_event_id_mapping(machine_vertices: Iterable[Tuple[MachineVertex, str]] | None)[source]
Parameters:

machine_vertices (list(tuple(MachineVertex,str))) –

create_device_atom_event_id_mapping(devices: Iterable[LiveOutputDevice])[source]

Add output mappings for devices.

property database_path: str
Return type:

str