Belle II Software development
|
Provides functionality to send mails in case of failed scripts / validation plots. More...
Public Member Functions | |
def | __init__ (self, validation, include_expert_plots=False) |
Initializes an instance of the Mail class from an instance of the Validation class. | |
def | send_all_mails (self, incremental=None) |
def | write_log (self) |
Protected Member Functions | |
Dict[str, Dict[str, str]] | _create_mail_log_failed_scripts (self) |
Looks up all scripts that failed and collects information about them. | |
Dict[str, Dict[str, Dict[str, str]]] | _create_mail_log (self, comparison, include_expert_plots=False) |
Takes the entire comparison json file, finds all the plots where comparison failed, finds info about failed scripts and saves them in the following format: | |
Static Protected Member Functions | |
Dict[str, Dict[str, Dict[str, str]]] | _flag_new_failures (Dict[str, Dict[str, Dict[str, str]]] mail_log, Optional[Dict[str, Dict[str, Dict[str, str]]]] old_mail_log) |
bool | _check_if_same (Dict[str, Dict[str, str]] plot_errors) |
def | _compose_message (plots, incremental=True) |
Takes a dict (like in _create_mail_log) and composes a mail body. | |
bool | _force_full_report () |
Protected Attributes | |
_validator | |
Instance of validation.Validation. | |
_mail_data_old | |
Yesterday's mail data (generated from comparison_json). | |
_mail_data_new | |
Current mail data. | |
Provides functionality to send mails in case of failed scripts / validation plots.
The mail data is built upon instantiation, the send_mails
method sends the actual mails.
Definition at line 45 of file mail_log.py.
def __init__ | ( | self, | |
validation, | |||
include_expert_plots = False |
|||
) |
Initializes an instance of the Mail class from an instance of the Validation class.
Assumes that a comparison json file exists, reads it and parses it to extract information about failed plots. This information, together with information about failed scripts, gets stored in self.mail_data_new. If there is mail_data.json inside the log folder, its contents get stored in self.mail_data_old for later comparison.
validation | validation.Validation instance |
include_expert_plots | Should expert plots be included? |
Definition at line 54 of file mail_log.py.
|
staticprotected |
@param plot_errors: ``_create_mail_log[contact]``. @return True, if there is at least one new/changed plot status
Definition at line 287 of file mail_log.py.
|
staticprotected |
Takes a dict (like in _create_mail_log) and composes a mail body.
plots | |
incremental | (bool): Is this an incremental report or a full ("Monday") report? |
Definition at line 298 of file mail_log.py.
|
protected |
Takes the entire comparison json file, finds all the plots where comparison failed, finds info about failed scripts and saves them in the following format:
{ "email@address.test" : { "title1": { "package": str, "description": str, "rootfile": str, "comparison_text": str, "description": str, "comparison_result": str, "warnings": str, "file_url": str }, "title2": {...} }, "mail@...": {...} }
The top level ordering is the email address of the contact to make sure every user gets only one mail with everything in it.
Definition at line 165 of file mail_log.py.
|
protected |
Looks up all scripts that failed and collects information about them.
See :meth:_create_mail_log
for the structure of the resulting dictionary.
Definition at line 108 of file mail_log.py.
|
staticprotected |
Add a new field 'compared_to_yesterday' which takes one of the values 'unchanged' (same revision comparison result as in yesterday's mail log, 'new' (new warning/failure), 'changed' (comparison result changed).
Definition at line 248 of file mail_log.py.
|
staticprotected |
Should a full (=non incremental) report be sent? Use case e.g.: Send a full report every Monday.
Definition at line 398 of file mail_log.py.
def send_all_mails | ( | self, | |
incremental = None |
|||
) |
Send mails to all contacts in self.mail_data_new. If self.mail_data_old is given, a mail is only sent if there are new failed plots @param incremental: True/False/None (=automatic). Whether to send a full or incremental report.
Definition at line 408 of file mail_log.py.
def write_log | ( | self | ) |
Dump mail json.
Definition at line 473 of file mail_log.py.
|
protected |
Current mail data.
Will be filled on instantiation. Check docstring of _create_mail_log for exact format
Definition at line 104 of file mail_log.py.
|
protected |
Yesterday's mail data (generated from comparison_json).
Check docstring of _create_mail_log for exact format
Definition at line 95 of file mail_log.py.
|
protected |
Instance of validation.Validation.
Definition at line 71 of file mail_log.py.