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:
UDPConnectionA 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
NotificationProtocolclass without routing messages via SpiNNaker.- Parameters:
start_resume_callback_function – A function to be called when the start message has been received. This function should not take any parameters or return anything.
local_host – Optional specification of the local hostname or IP address of the interface to listen on
local_port – 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]) None[source]¶
Add a database callback to be called when the database is ready.
- Parameters:
database_callback_function – 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:
SQLiteDBA reader for the database.
- Parameters:
database_path – 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 – The label of the vertex
- Returns:
dictionary of event keys indexed by atom ID
- get_configuration_parameter_value(parameter_name: str) float | None[source]¶
Get the value of a configuration parameter.
- Parameters:
parameter_name – The name of the parameter
- Returns:
The value of the parameter
- get_ip_address(x: int, y: int) str | None[source]¶
Get an IP address to contact a chip.
- Parameters:
x – The x-coordinate of the chip
y – The y-coordinate of the chip
- Returns:
The IP address of the Ethernet to use to contact the chip
- 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.
Noneotherwise.
- 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 – The label of the vertex
- Returns:
dictionary of atom IDs indexed by event key
- 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 – The label of the pre vertex
receiver_label – The label of the post vertex
- Returns:
tuple of (IP address, port, strip SDP, board address, tag, chip_x, chip_y)
- class spinn_front_end_common.utilities.database.DatabaseUpdater(database_path: str)¶
Bases:
SQLiteDBA reader for the database.
- Parameters:
database_path – The path to the database
- class spinn_front_end_common.utilities.database.DatabaseWriter¶
Bases:
SQLiteDBThe 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 – 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 – Whether the database is in read-only mode. When the database is in read-only mode, it must already exist.
ddl_file – 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 used to create the rows of result sets. Either
tupleorsqlite3.Row(default); can beNoneto use the DB driver default.text_factory – Callable used to create the Python values of non-numeric columns in result sets. Usually
memoryview(default) but should bestrwhen you’re expecting string results; can beNoneto use the DB driver default.case_insensitive_like – Whether we want the
LIKEmatching operator to be case-sensitive or case-insensitive (default).timeout – 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.
- 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)
- 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
- create_atom_to_event_id_mapping(machine_vertices: Iterable[Tuple[MachineVertex, str]] | None) None[source]¶
Creates atom keys and stores them in the database.
- Parameters:
machine_vertices
- create_device_atom_event_id_mapping(devices: Iterable[LiveOutputDevice]) None[source]¶
Add output mappings for devices.