DBBC3Validation Module¶
This module is part of the DBBC3 package and implements higher level validation methods for verification of the proper initialization and configuration of the DBBC3 VLBI backend
A very simple example:
from dbbc3.DBBC3 import DBBC3
from dbbc3.DBBC3Validation import ValidationFactory, ValidationReport
import logging
dbbc3 = DBBC3("dbbc3")
val = ValidationFactory().create(dbbc3)
# print validation result
print (val.validateIFLevel("A"))
# log validation result
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
rep = val.validateIFLevel("A")
rep.log(logger)
Item class¶
- class Item(level='', action='', message='', resolution='', state='', exit=False)¶
Storage class to hold information about one validation check provided by one of the DBBC3 validation methods. Instances of this class can be passed to
ValidationReportvia theValidationReport.add()method to provde a user friendly representation of the validation procedure.The class provides these constants for specifying the reporting level:
INFO WARN ERROR
The class provides these constants for specifying the validation state:
OK FAIL
- Parameters:
level (str) – the reporting level of the validation item (see levels above)
action (str) – a description of the validation action that was performed
message (str) – a message describing the outcome of the validation action
resolution (str, optional) – a resolution message to be displayed in case validation errors have occured
state (str) – a string describing the state of the validation action
exit (boolean) – True indicates that processing should stop in case of a validation failure (default: False)
Note
Setting exit=True only indicates that validation failure is considered to be critical. Handling of the exit condition is not done by this class or by
ValidationReportand must be handled in the upsteam code calling the validation actions
ValidationReport class¶
- class ValidationReport(ignoreErrors=False)¶
Reporter class to provide human readable reports and/or logs of validation actions. Each report can consist of multiple validation items represented by an
Iteminstance.If any of the validation items has failed and has an exit condition the exit attribute of this class is set to True (unless overridden by the py:attr:ignoreErrors argument.
- Parameters:
ignoreErrors (boolean) – If True a validation failure in any of the validation items will not set an exit condition (default: False)
- add(item)¶
Add a validation item to the report
If the item contains an exit condition (item.exit = True) the self.exit member is set to True unless the ignoreErrors parameter was set on initiliazation
- Parameters:
item (Item) – the validation Item instance to add
- clear()¶
Reset the contents of the ValidationReport
- log(logger)¶
Write all validation items attached to the report to the log.
Depending on the item.level string each logger entry will have either the info, warning or error log levels:
item.level contains "INFO" => log level info item.level contains "WARN" => log level warning item.level contains "ERROR" => log level error
The message test will be formated in the following way:
[item.state] item.action - item.message
if the validation item contains a non-empty resolution field an additional line will be logged with the following format:
[RESOLUTION] item.resolution
- Parameters:
logger (
logging.Logger) – the logger object to use for logging the output
- property exit¶
True if at least one of the validation items has failed with an exit condition
- Type:
boolean
- property items¶
Returns the list of report items attached to this ValidationReport
- Returns:
the list of reporting items
- Return type:
list of
Item
- property numError¶
the total number of errors raised for all validation items of this report
- Type:
int
- property numWarnings¶
the total number of warnings raised for all validation items of this report
- Type:
int
ValidationFactory class¶
- class ValidationFactory¶
Factory class for providing the matching DBBC3Validation sub-class for the currently active DBBC3 mode and software version.
In order to function all derived DBBC3Validation classes must follow the naming convention:
DBBC3Validation_mode_majorversione.g. DBBC3Validation_OCT_D_120 for mode OCT_D major version 120
- create(dbbc3, ignoreErrors=False)¶
Return a DBBC3Validation sub-class object matching the current mode and software version of the DBBC3 as specified in dbbc3.config
- Parameters:
dbbc3 (DBBC3) – the active DBBC3 instance
ignoreErrors (boolean, optional) – If True do not exit processing in case of validation failures (default: False)
- Returns:
the instance of the validation class matching the current mode and software version