calibpipe.database.adapter.database_containers package#

Contain database containers for CalibPipe and the table version manager.

All CalibPipe data is defined at the database level in this sub-package. In particular, a SQLTableInformation can be found for each CalibPipe container.

In addition, two utilities are present here to ease the use of DB containers:

  • TableVersionManager: Creates tables objects specific to a version number (needed for CalibPipe data).

  • ContainerMap: Maps CalibPipe containers (ultimately ctapipe.core.container) to database table information. The mapping is built-in, and allows users to quickly access the DB container corresponding to a CalibPipe container (or the contrary).

class calibpipe.database.adapter.database_containers.TableVersionManager[source]#

Bases: object

Create versioned tables for CalibPipe.

The main method is apply_version() that returns a table given a table information and a version. The returned table will contain the same data as the table information and have a unique name containing the common table name and the software version.

static get_safe_version_string(version: str) str[source]#

Create a string from a version that is safe for table names.

static update_version(old_name: str, version: str) str[source]#

Update the DB object name with a new version number.

static apply_version(table_info: SQLTableInfo, version: str | None = None) Table[source]#

Create a DB object class with a particular version number.

class calibpipe.database.adapter.database_containers.ContainerMap[source]#

Bases: object

Map CalibPipe and database containers.

The correspondence must be set using the register_container_pair() method, called automatically for the built-in CalibPipe containers. Once set, this map allows us to quickly get the DB container associated to a CalilbPipe container (or contrary) to switch between the two worlds.

cp_container#

alias of Container

db_container_info#

alias of SQLTableInfo

cp_container_type#

alias of type[Container]

static map_to_cp_container(db_container: SQLTableInfo) type[Container][source]#

Return the CalibPipe container corresponding to a DB container.

static map_to_db_container(cp_container: type[Container]) SQLTableInfo[source]#

Return the DB container corresponding to a CalibPipe container.

static get_cp_containers() list[source]#

Return the list of registered CalibPipe containers.

static register_container_pair(cp_container: type[Container], db_container: SQLTableInfo) None[source]#

Associate a CalibPipe container and a DB container.

static unregister_container_pair(cp_container: type[Container], db_container: SQLTableInfo) None[source]#

Deassociate a CalibPipe container and a DB container.

Submodules#

calibpipe.database.adapter.database_containers.atmosphere module#

Atmospheric SQL table info.

calibpipe.database.adapter.database_containers.common_metadata module#

Common Metadata SQL info.

calibpipe.database.adapter.database_containers.container_map module#

ContainerMap class.

class calibpipe.database.adapter.database_containers.container_map.ContainerMap[source]#

Bases: object

Map CalibPipe and database containers.

The correspondence must be set using the register_container_pair() method, called automatically for the built-in CalibPipe containers. Once set, this map allows us to quickly get the DB container associated to a CalilbPipe container (or contrary) to switch between the two worlds.

cp_container#

alias of Container

db_container_info#

alias of SQLTableInfo

cp_container_type#

alias of type[Container]

static map_to_cp_container(db_container: SQLTableInfo) type[Container][source]#

Return the CalibPipe container corresponding to a DB container.

static map_to_db_container(cp_container: type[Container]) SQLTableInfo[source]#

Return the DB container corresponding to a CalibPipe container.

static get_cp_containers() list[source]#

Return the list of registered CalibPipe containers.

static register_container_pair(cp_container: type[Container], db_container: SQLTableInfo) None[source]#

Associate a CalibPipe container and a DB container.

static unregister_container_pair(cp_container: type[Container], db_container: SQLTableInfo) None[source]#

Deassociate a CalibPipe container and a DB container.

calibpipe.database.adapter.database_containers.observatory module#

Observatory SQL table info.

calibpipe.database.adapter.database_containers.table_version_manager module#

TableVersionManager class.

class calibpipe.database.adapter.database_containers.table_version_manager.TableVersionManager[source]#

Bases: object

Create versioned tables for CalibPipe.

The main method is apply_version() that returns a table given a table information and a version. The returned table will contain the same data as the table information and have a unique name containing the common table name and the software version.

static get_safe_version_string(version: str) str[source]#

Create a string from a version that is safe for table names.

static update_version(old_name: str, version: str) str[source]#

Update the DB object name with a new version number.

static apply_version(table_info: SQLTableInfo, version: str | None = None) Table[source]#

Create a DB object class with a particular version number.

calibpipe.database.adapter.database_containers.throughput module#

OpticalThroughput SQL info.

calibpipe.database.adapter.database_containers.version_control module#

SQL info for run metadata.