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.
- 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.
- get_configuration_parameter_value(parameter_name: str) float | None [source]¶
Get the value of a configuration parameter.
- 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:
- 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.
- 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 settingread_only=True
.row_factory (Callable or None) – Callable used to create the rows of result sets. Either
tuple
orsqlite3.Row
(default); can beNone
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 bestr
when you’re expecting string results; can beNone
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:
- 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
- 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:
- 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.