KPI: increase error robustness of KPI checks
antje-s opened this issue · 6 comments
Dear pywmcp team,
the KPI checks are running fine. I just noticed that in case of problems with single KPI check the script aborts completely. It would be good to jump to the next KPI check in case of problems, so that all KPI checks are tried for each metadata record.
Examples:
-
Links check failed:
urn%3Ax-wmo%3Amd%3Aint.wmo.wis%3A%3ACSCZ10OKPR.xml
-->
[2021-05-31T06:38:56Z] INFO - Running KPI-8: Links health
[2021-05-31T06:38:56Z] INFO - "http://wis.wmo.int/2012/codelists/WMOCodeLists.xml#WMO_GTSProductCategoryCode" cannot be resolved!
--> not checked KPI-9 / KPI-10 / KPI-11 / KPI-12 -
undefined namespace prefix
urn%3Ax-wmo%3Amd%3Aint.eumetsat%3AEO%3AEUM%3ADAT%3ASENTINEL-3%3ASR_1_SRA_A___NTC.xml
-->
[2021-05-31T07:21:37Z] INFO - Running KPI-7: Graphic overview for non bulletins metadata records
--> not checked KPI-8 / KPI-9 / KPI-10 / KPI-11 / KPI-12
call via command line for single xml returned:
...
File "...python3.6/site-packages/pywcmp-0.3.dev0-py3.6.egg/pywcmp/kpi.py", line 962, in evaluate
result = getattr(self, kpi)()
File "...python3.6/site-packages/pywcmp-0.3.dev0-py3.6.egg/pywcmp/kpi.py", line 531, in kpi_007
graphic_overviews = self.exml.xpath(xpath, namespaces=self.namespaces)
File "src/lxml/etree.pyx", line 2296, in lxml.etree._ElementTree.xpath
File "src/lxml/xpath.pxi", line 357, in lxml.etree.XPathDocumentEvaluator.call
File "src/lxml/xpath.pxi", line 225, in lxml.etree._XPathEvaluatorBase._handle_result
lxml.etree.XPathEvalError: Undefined namespace prefix
Kind regards
Antje
Many thanks @josusky and @tomkralidis
No problem I will do that and get back to you
One step further, it continues to run even with unsuccessful link check, but there is still a problem with KPI 11
e.g.
urn:x-wmo:md:int.eumetsat:EO:EUM:DAT:SENTINEL-3:SR_1_SRA_A___NTC.xml
now stopped at
[2021-06-04T06:28:09Z] INFO - Running KPI-11: Codelists validation
...
File "/home/wis/myScripts/venv/pywcmp/lib64/python3.6/site-packages/pywcmp-0.3.dev0-py3.6.egg/pywcmp/kpi.py", line 851, in kpi_011
if xpath2.text in self.codelists[key][codelist]:
KeyError: 'MD_DistributionScopeCode'
...
OK, I have added one more exception handling into KPI-11, so now it will report:
"Line 377: Invalid code list reference: 'MD_DistributionScopeCode' is not defined in 'wmo'"
and keep going.
Thanks @josusky, I updated my repository with the latest development version from source and start a new run
...looks good, now runs completely through - thanks again