nexusLIMS.db.session_handler#
Classes and methods to interact with sessions from the NexusLIMS database.
Module Contents#
Classes#
A representation of a session in the NexusLIMS database. |
Functions#
Get list of sessions that need to be built from the NexusLIMS database. |
|
Fetch all session logs from the database and return SessionLogs. |
API#
- class nexusLIMS.db.session_handler.Session(session_identifier: str, instrument: Instrument, dt_range: Tuple[datetime, datetime], user: str)[source]#
A representation of a session in the NexusLIMS database.
A record of an individual session as read from the Nexus Microscopy facility session database. Created by combining two
SessionLogobjects with status"TO_BE_BUILT".- Parameters:
session_identifier – The unique identifier for an individual session on an instrument
instrument – An object representing the instrument associated with this session
dt_range – A tuple of two
datetimeobjects representing the start and end of this session )in that orderuser (str) – The username associated with this session (may not be trustworthy)
- update_session_status(status: RecordStatus)[source]#
Update the status of this Session in the NexusLIMS database.
Specifically, update the
record_statusin any session logs for thisSession.- Parameters:
status (RecordStatus) – The new status for this session (type-safe enum value)
- Returns:
success – Whether the update operation was successful
- Return type:
- insert_record_generation_event() dict[source]#
Insert record generation event to session log.
Insert a log for this session into the session database with
event_type"RECORD_GENERATION"and the current time (with local system timezone) as the timestamp.- Returns:
res – A dictionary containing the inserted log information
- Return type:
- nexusLIMS.db.session_handler.get_sessions_to_build() list[Session][source]#
Get list of sessions that need to be built from the NexusLIMS database.
Query the NexusLIMS database for pairs of logs with status
TO_BE_BUILTand return the information needed to build a record for that session.
- nexusLIMS.db.session_handler.get_all_session_logs() list[SessionLog][source]#
Fetch all session logs from the database and return SessionLogs.
- Returns:
session_logs – A list of all SessionLog objects from the database, ordered by timestamp. Will be an empty list if there are no session logs.
- Return type: