lsst.sims.ocs.database.socs_db module

class lsst.sims.ocs.database.socs_db.SocsDatabase(sqlite_save_path=None, session_id_start=None, sqlite_session_save_path=None)[source]

Bases: future.types.newobject.newobject

Main class for simulation database interaction.

This class is responsible for interacting with the main SQLite simulation database. This consists of a machine session tracking database and individual database files for each run session of the simulation.

db_dialect

str – The flavor of the database to use. Options: sqlite.

metadata

sqlalchemy.MetaData – The instance for holding the relevant tables.

engine

sqlalchemy.engine.Engine – The instance of the database engine.

sqlite_save_path

str – A path to save all resulting database files for SQLite.

sqlite_session_save_path

str – A path to save the SQLite session tracking database.

session_engine

sqlalchemy.engine.Engine – The session specific instance of the database engine. SQLite only.

session_metadata

sqlalchemy.MetaData – The instance for holding the session specific tables. SQLite only.

session_start

int – A new starting session Id for counting new simulations.

Initialize the class.

Parameters:
  • sqlite_save_path (str) – A path to save all resulting database files for SQLite.
  • session_id_start (int) – A new starting session Id for counting new simulations.
append_data(table_name, table_data)[source]

Collect information for the provided table.

Parameters:
  • table_name (str) – The attribute name holding the sqlalchemy.Table instance.
  • table_data (topic) – The Scheduler topic data instance.
clear_data()[source]

Clear all stored data lists.

create_db()[source]

Create the database tables.

This function does the actual work of creating all the relevant database tables. This creates the session tracking database with the Session table.

new_session(run_comment)[source]

Log a new session to the database and return the ID.

This function logs a new session to the database and returns the session ID. This writes an entry to the session tracking database. Then a session ID specific database is created and the information is replicated in that Session table. Since SQLite auto increment values always start at one, an offset is applied to make the session IDs commensurate with OpSim3 style ones.

Parameters:run_comment (str) – The startup comment for the simulation run.
Returns:int – The session ID for this simulation run.
write()[source]

Write collected information into the database.

write_table(table_name, table_data)[source]

Collect information for the provided table.

Parameters:
  • table_name (str) – The attribute name holding the sqlalchemy.Table instance.
  • table_data (list[topic]) – A set of Scheduler topic data instances.
data_empty

bool – Is internal data list empty