SND@LHC Software
|
Conditions Database Interface definition. More...
Public Member Functions | |
list_detectors (self, parent_id=None) | |
Returns a list with all the detector names in the database. | |
get_detector (self, detector_id) | |
Returns a detector dictionary. | |
add_detector (self, name, parent_id=None) | |
Adds a new detector to the database. | |
remove_detector (self, detector_id) | |
Removes a detector from the database. | |
add_condition (self, detector_id, name, tag, values, type=None, collected_at=datetime.now(), valid_since=datetime.now(), valid_until=datetime.max) | |
Adds a condition to a detector. | |
get_conditions (self, detector_id) | |
Returns a list with all condition dictionaries associated with a detector. | |
get_conditions_by_name (self, detector_id, name) | |
Returns a list with condition dictionaries having a specific name for a given detector. | |
get_conditions_by_tag (self, detector_id, tag) | |
Returns a list with condition dictionaries having a specific tag for a given detector. | |
get_conditions_by_name_and_validity (self, detector_id, name, start_date, end_date=None) | |
Returns a list with condition dictionaries associated with a detector that are valid on the specified date. | |
get_condition_by_name_and_tag (self, detector_id, name, tag) | |
Returns a condition dictionary of a specific condition belonging to a detector, identified by condition name and tag. | |
get_condition_by_name_and_collection_date (self, detector_id, name, collected_at) | |
Returns a condition dictionary of a specific condition belonging to a detector, identified by condition name and collection date/time. | |
update_condition_by_name_and_tag (self, detector_id, name, tag, type=None, valid_since=None, valid_until=None) | |
Updates the type, valid_since and valid_until values of a specific condition belonging to a detector, identified by condition name and tag. | |
Conditions Database Interface definition.
This class defines the interface that all storage back-end adapters must implement. TODO uncomment for python >= 3.8: @final
Definition at line 24 of file interface.py.
conditionsDatabase.interface.APIInterface.add_condition | ( | self, | |
detector_id, | |||
name, | |||
tag, | |||
values, | |||
type = None , |
|||
collected_at = datetime.now() , |
|||
valid_since = datetime.now() , |
|||
valid_until = datetime.max |
|||
) |
Adds a condition to a detector.
detector_id | String identifying the detector to which the condition will be added (i.e. 'muonflux/driftTubes'). |
name | String specifying the name of the condition (e.g. 'strawPositions'). |
tag | String specifying a tag for the condition. Must be unique for the same condition name. |
values | The values of the condition. Can be any data type. |
type | (optional) String specifying the type of condition (e.g. 'calibration'). |
collected_at | (optional) Timestamp specifying the date/time the condition was acquired. Must be unique w.r.t. the condition name. Can be of type String or datetime. This timestamp will be stored with an accuracy up to seconds. If unspecified, this value will be set to 'datetime.now'. |
valid_since | (optional) Timestamp specifying the date/time as of when the condition is valid. Can be of type String or datetime. This timestamp will be stored with an accuracy up to seconds. If unspecified, this value will be set to 'datetime.now'. |
valid_until | (optional) Timestamp specifying the date/time up until the condition is valid. Can be of type String or datetime. If unspecified, this value will be set to 'datetime.max'. This timestamp will be stored with an accuracy up to seconds. |
TypeError | If input type is not as specified. |
ValueError | If detector_id does not exist. |
Reimplemented in conditionsDatabase.databases.mongodb.mongodbadapter.MongoToCDBAPIAdapter.
Definition at line 94 of file interface.py.
conditionsDatabase.interface.APIInterface.add_detector | ( | self, | |
name, | |||
parent_id = None |
|||
) |
Adds a new detector to the database.
name | String specifying the name for the new detector. Must be unique. Must not contain a forward slash (i.e. /). |
parent_id | (optional) String identifying the parent detector the new detector should be added to as subdetector. |
TypeError | If input type is not as specified. |
ValueError | If parent_id does not exist. |
Reimplemented in conditionsDatabase.databases.mongodb.mongodbadapter.MongoToCDBAPIAdapter.
Definition at line 57 of file interface.py.
conditionsDatabase.interface.APIInterface.get_condition_by_name_and_collection_date | ( | self, | |
detector_id, | |||
name, | |||
collected_at | |||
) |
Returns a condition dictionary of a specific condition belonging to a detector, identified by condition name and collection date/time.
This combination must be unique.
detector_id | String identifying the detector for which the condition must be retrieved (i.e. 'muonflux/driftTubes'). |
name | String specifying the name of the conditions to be retrieved (e.g. 'strawPositions'). |
collected_at | Timestamp specifying the moment on which the condition was collected/measured. Can be of type String or datetime. Collection dates are stored with accuracy up to seconds. |
TypeError | If input type is not as specified. |
ValueError | If detector_id does not exist. |
Dict | A dictionary adhering to the following specification: Condition = { 'name': String, 'tag': String, 'type': String, 'collected_at': datetime, 'valid_since': datetime, 'valid_until': datetime, 'values': mixed } |
Reimplemented in conditionsDatabase.databases.mongodb.mongodbadapter.MongoToCDBAPIAdapter.
Definition at line 202 of file interface.py.
conditionsDatabase.interface.APIInterface.get_condition_by_name_and_tag | ( | self, | |
detector_id, | |||
name, | |||
tag | |||
) |
Returns a condition dictionary of a specific condition belonging to a detector, identified by condition name and tag.
This combination must be unique.
detector_id | String identifying the detector for which the condition must be retrieved (i.e. 'muonflux/driftTubes'). |
name | String specifying the name of the conditions to be retrieved (e.g. 'strawPositions'). |
tag | String specifying the tag of the condition to be retrieved. |
TypeError | If input type is not as specified. |
ValueError | If detector_id does not exist. |
Dict | A dictionary adhering to the following specification: Condition = { 'name': String, 'tag': String, 'type': String, 'collected_at': datetime, 'valid_since': datetime, 'valid_until': datetime, 'values': mixed } |
Reimplemented in conditionsDatabase.databases.mongodb.mongodbadapter.MongoToCDBAPIAdapter.
Definition at line 182 of file interface.py.
conditionsDatabase.interface.APIInterface.get_conditions | ( | self, | |
detector_id | |||
) |
Returns a list with all condition dictionaries associated with a detector.
detector_id | String identifying the detector for which the conditions must be retrieved (i.e. 'muonflux/driftTubes'). |
TypeError | If input type is not as specified. |
ValueError | If detector_id does not exist. |
List | A list with condition dictionaries adhering to the following specification: Condition = { 'name': String, 'tag': String, 'type': String, 'collected_at': datetime, 'valid_since': datetime, 'valid_until': datetime, 'values': mixed } |
Reimplemented in conditionsDatabase.databases.mongodb.mongodbadapter.MongoToCDBAPIAdapter.
Definition at line 110 of file interface.py.
conditionsDatabase.interface.APIInterface.get_conditions_by_name | ( | self, | |
detector_id, | |||
name | |||
) |
Returns a list with condition dictionaries having a specific name for a given detector.
detector_id | String identifying the detector for which the conditions must be retrieved (i.e. 'muonflux/driftTubes'). |
name | String specifying the name of the conditions to be retrieved (e.g. 'strawPositions'). |
TypeError | If input type is not as specified. |
ValueError | If detector_id does not exist. |
List | A list with condition dictionaries adhering to the following specification: Condition = { 'name': String, 'tag': String, 'type': String, 'collected_at': datetime, 'valid_since': datetime, 'valid_until': datetime, 'values': mixed } |
Reimplemented in conditionsDatabase.databases.mongodb.mongodbadapter.MongoToCDBAPIAdapter.
Definition at line 126 of file interface.py.
conditionsDatabase.interface.APIInterface.get_conditions_by_name_and_validity | ( | self, | |
detector_id, | |||
name, | |||
start_date, | |||
end_date = None |
|||
) |
Returns a list with condition dictionaries associated with a detector that are valid on the specified date.
detector_id | String identifying the detector for which the condition must be retrieved (i.e. 'muonflux/driftTubes'). |
name | String specifying the name of the conditions to be retrieved (e.g. 'strawPositions'). |
start_date | Timestamp specifying a start of a date/time range for which conditions must be valid. Can be of type String or datetime. |
end_date | (optional) Timestamp specifying the end of a date/time range for which conditions must be valid. If not specified then we will query for validity on the start_date. Can be of type String or datetime |
TypeError | If input type is not as specified. |
ValueError | If detector_id does not exist. |
List | A list with condition dictionaries adhering to the following specification: Condition = { 'name': String, 'tag': String, 'type': String, 'collected_at': datetime, 'valid_since': datetime, 'valid_until': datetime, 'values': mixed } |
Reimplemented in conditionsDatabase.databases.mongodb.mongodbadapter.MongoToCDBAPIAdapter.
Definition at line 165 of file interface.py.
conditionsDatabase.interface.APIInterface.get_conditions_by_tag | ( | self, | |
detector_id, | |||
tag | |||
) |
Returns a list with condition dictionaries having a specific tag for a given detector.
detector_id | String identifying the detector for which the condition must be retrieved (i.e. 'muonflux/driftTubes'). |
tag | String specifying the tag of the condition to be retrieved. |
TypeError | If input type is not as specified. |
ValueError | If detector_id does not exist. |
List | A list with condition dictionaries adhering to the following specification: Condition = { 'name': String, 'tag': String, 'type': String, 'collected_at': datetime, 'valid_since': datetime, 'valid_until': datetime, 'values': mixed } |
Reimplemented in conditionsDatabase.databases.mongodb.mongodbadapter.MongoToCDBAPIAdapter.
Definition at line 141 of file interface.py.
conditionsDatabase.interface.APIInterface.get_detector | ( | self, | |
detector_id | |||
) |
Returns a detector dictionary.
detector_id | String identifying the detector to retrieve (i.e. 'muonflux/driftTubes'). |
TypeError | If input type is not as specified. |
ValueError | If detector_id does not exist. |
Dict | A dictionary adhering to the following specification: Detector = { 'name': String, 'subdetectors': List of Detector, 'conditions': List of Condition } |
Reimplemented in conditionsDatabase.databases.mongodb.mongodbadapter.MongoToCDBAPIAdapter.
Definition at line 46 of file interface.py.
conditionsDatabase.interface.APIInterface.list_detectors | ( | self, | |
parent_id = None |
|||
) |
Returns a list with all the detector names in the database.
detector_id | (optional) String identifying the parent detector to retrieve the (sub)detector names for (i.e. 'muonflux/driftTubes'). |
TypeError | If input type is not as specified. |
ValueError | If parent_id does not exist. |
List | A list with (string) names of detectors under the specified parent. |
Reimplemented in conditionsDatabase.databases.mongodb.mongodbadapter.MongoToCDBAPIAdapter.
Definition at line 34 of file interface.py.
conditionsDatabase.interface.APIInterface.remove_detector | ( | self, | |
detector_id | |||
) |
Removes a detector from the database.
Caution: all conditions associated with this detector will be permanently removed as well!
detector_id | String identifying the detector to remove (i.e. 'muonflux/driftTubes'). |
TypeError | If input type is not as specified. |
ValueError | If detector_id does not exist. |
Reimplemented in conditionsDatabase.databases.mongodb.mongodbadapter.MongoToCDBAPIAdapter.
Definition at line 67 of file interface.py.
conditionsDatabase.interface.APIInterface.update_condition_by_name_and_tag | ( | self, | |
detector_id, | |||
name, | |||
tag, | |||
type = None , |
|||
valid_since = None , |
|||
valid_until = None |
|||
) |
Updates the type, valid_since and valid_until values of a specific condition belonging to a detector, identified by condition name and tag.
detector_id | String identifying the detector for which the condition must be updated (i.e. 'muonflux/driftTubes'). |
name | String specifying the name of the conditions to be updated (e.g. 'strawPositions'). |
tag | String specifying the tag of the condition to be updated. |
type | (optional) String specifying the type of condition (e.g. 'calibration'). |
valid_since | (optional) Timestamp specifying the date/time as of when the condition is valid. Can be of type String or datetime. |
valid_until | (optional) Timestamp specifying the date/time up until the condition is valid. Can be of type String or datetime. |
TypeError | If input type is not as specified. |
ValueError | If detector_id does not exist. |
Reimplemented in conditionsDatabase.databases.mongodb.mongodbadapter.MongoToCDBAPIAdapter.
Definition at line 221 of file interface.py.