dquality.hdf_dependency

Please make sure the installation Pre-requisites are met.

This module verifies that each of the PVs listed in the configuration file exist and their values are set within the predefined range.

The results will be reported in a file (printed on screen for now). An error will be reported back to UI via PV.

Functions:

init(config) This function initializes global variables.
verify(conf, file) This function reads the json “dependencies” file from the dqconfig.ini file.
verify_list(file, list, relation, logger) This function takes an hd5 file, a list of tags (can be extended) and a relation between the list members.
find_value(tag, dset) This function takes tag parameter and a corresponding dataset from the hd5 file.
dquality.hdf_dependency.init(config)[source]

This function initializes global variables. It gets values from the configuration file, evaluates and processes the values. If mandatory file or directory is missing, the script logs an error and exits.

Parameters:config (str) – configuration file name, including path
Returns:
  • logger (Logger) – logger instance
  • dep (dictionary) – a dictionary containing dependency values read from the configured ‘dependencies’ file
dquality.hdf_dependency.verify(conf, file)[source]

This function reads the json “dependencies” file from the dqconfig.ini file. This file contains dictionary with keys of relations between tags. The value is a list of lists. The relation applies to the tags in inner list respectively. For example if the relation is “equal”, all tags in each inner list must be equal,The outer list hold the lists that apply the relation. A first element in a inner list is an “anchor” element, so all elements are compared to it. This is important for the “less_than” type of relation, when the order of parameters is important.

The allowed keys are:

  • less_than” - the PV value must be less than attribute value
  • less_or_equal” - the PV value must be less than or equal attribute value
  • equal” - the PV value must be equal to attribute value
  • greater_or_equal” - the PV value must be greater than or equal attribute value
  • greater_than” - the PV value must be greater than attribute value

The tag in a “dependencies” file can be an hd5 tag, or can have appended keyword “dim” and an numeric value indicating axis. If the tag is simple hd5 tag, the verifier compares the value of this tag. If it has the “dim” keyword appended, the verifier compares a specified dimension.

Any vakue that does not agree with the configured relation is reported (printed for now). The function returns True if no error was found and False otherwise.

Parameters:
  • conf (str) – configuration file name, including path
  • file (str) – File Name to verify including path
Returns:

boolean

dquality.hdf_dependency.verify_list(file, list, relation, logger)[source]

This function takes an hd5 file, a list of tags (can be extended) and a relation between the list members. First the method creates a tags dictionary from the list of tags. The key is a simple hd5 tag, and the value is a newly created TagValue instance that contains extended tag (or simple tag if simple tag was in the list), and a placeholder for the value. The first tag from the list is retained as an anchor.

The function travers through all tags in the given file. If the tag name is found in the tags dictionary, the `find_value` method is called to retrieve a defined valueu referenced by the tag. The value is then added to the TagValue instance for this tag.

When all tags are processed the function iterates over the tags dictionary to find if the relation between anchor value and other values can be verified. If any relation is not true, a report is printed for this tag, and the function will return `False`. Otherwise the function returns `True`.

Parameters:
  • file (file) – an hd5 file to be verified
  • list (list) – list of extended or simple hd5 tags
  • relation (str) – a string specifying the relation between tags in the list
  • logger (Logger) – a Logger instance
Returns:

boolean

dquality.hdf_dependency.find_value(tag, dset)[source]

This function takes tag parameter and a corresponding dataset from the hd5 file. The tag can be a simple hd5 member tag or extended tag. This function assumes that the extended tag is a string containing hd5 tag, a word indicating the tag category (i.e. “dim” meaning dimension), and a parameter (i.e. numeric index). In the case of a simple hd5 tag the function returns a value of this member. In the second case the function returns decoded value, in the case of “dim” category, it returns the indexed dimension.

Parameters:
  • tag (str) – a simple hd5 tag or extended
  • dset (dataset) – hd5 dataset corresonding to the tag parameter
Returns:

value of decoded tag