Closed lbesnard closed 8 years ago
@lbesnard Ok I can see what's happening :)
The following is finding the cchecker.py file and importing it as a module. In the past this happened to work because the script was importing the ComplianceChecker class into it's namespace and you were referencing it through that.
netcdf_checker_path = os.path.dirname(os.path.realpath(os.environ.get('NETCDF_CHECKER')))
sys.path.insert(0, netcdf_checker_path)
import cchecker
This can be greatly simplified by just using the compliance_checker library directly without the middle hop, as follows:
import tempfile
from compliance_checker.runner import ComplianceChecker
netcdf_file_path='/mnt/imos-test-data/IMOS/FAIMMS/Heron_Island/Relay_Pole_1/sea_water_temperature@1.7m_channel_26/2009/NO_QAQC/IMOS_FAIMMS_T_20090101T000000Z_HIRP1_FV00.nc'
tmp_json_checker_output = tempfile.mkstemp()
test='imos'
return_value, errors = ComplianceChecker.run_checker(netcdf_file_path, [test] , 'None', 'normal', tmp_json_checker_output[1], 'json')
hum thanks @lwgordonimos but does this work for you ? it doesnt work for me on nsp14
@lbesnard The "checkers" dictionary in the CheckSuite class looks like it is only populated when the _load_all_availablecheckers() class method is called, otherwise it leaves the 'checkers' dictionary as empty and it fails to run.
If I modify runner.py and add an explicit call to the load method(my change prepended with '+' below), it looks like the check passes.
class ComplianceChecker(object):
"""
Compliance Checker runner class.
Ties together the entire compliance checker framework, is used from
the command line or can be used via import.
"""
@classmethod
def run_checker(cls, ds_loc, checker_names, verbose, criteria, output_filename='stdout', output_format='stdout'):
"""
Static check runner.
@param ds_loc Dataset location (url or file)
@param checker_names List of string names to run, should match keys of checkers dict (empty list means run all)
@param verbose Verbosity of the output (0, 1, 2)
@param criteria Determines failure (lenient, normal, strict)
@param output_filename Path to the file for output
@param output_format Format of the output
@returns If the tests failed (based on the criteria)
"""
cs = CheckSuite()
+ cs.load_all_available_checkers()
Sure enough, the command line version contains a call to this method before running the check:
cchecker.py
def main():
# Load all available checker classes
check_suite = CheckSuite()
check_suite.load_all_available_checkers()
I will raise it as an upstream bug :)
Hmm, actually, no I won't... it is mentioned near the bottom of this page in the README:
https://github.com/ioos/compliance-checker/
Looks like the expectation is that your code will run that method before running the check... not sure why this isn't built into the call to "run_checker", but it may be intentional for some reason!
With that in mind, try the following(adding the lines marked with '+'):
import tempfile
from compliance_checker.runner import ComplianceChecker, CheckSuite
+cs = CheckSuite()
+cs.load_all_available_checkers()
netcdf_file_path='/mnt/imos-test-data/IMOS/FAIMMS/Heron_Island/Relay_Pole_1/sea_water_temperature@1.7m_channel_26/2009/NO_QAQC/IMOS_FAIMMS_T_20090101T000000Z_HIRP1_FV00.nc'
tmp_json_checker_output = tempfile.mkstemp()
test='imos'
return_value, errors = ComplianceChecker.run_checker(netcdf_file_path, [test] , 'None', 'normal', tmp_json_checker_output[1], 'json')
thanks a lot @lwgordonimos Check this out https://github.com/ioos/compliance-checker/commit/cb32e33576003dcfdba7259c6705f537f9302091
This is why ! We pulled out a new version of the checker and it was behaving differently !
and for example, this doesn't work with the current version in the PO.
@lbesnard Yes I noticed that change in the code as well looking at the commit history. At least it neatly explains it!
Re PO: no worries, I'll get that sorted out today.
FAIMMS, ANMN NRS DARWIN YONGALA and SOOP TRV scripts runs as CRONTAB everyday. They also use the NETCDF-CHECKER before pushing a new file to the $INCOMING_DIR to prevent bad files to be downloaded and pushed. This used to work with no issues until last tuesday night on both NSP14 and AWS10.
The issue seems to be related to a bad installation of the IOOS CHECKER/plugin system.
On NSP14, run ipython, and paste the following lines
This will fail with the following message :
A bit hard to debug, since the PO box doesn't reflect what is on NSP14 and AWS10. This again shows how important it is to have the PO box similar to what is on prod.
However the issue can be tracked down to this file and line
/var/lib/netcdf-checker/compliance_checker/runner.py" Line 34
It looks like the tests are not known. The checker plugins was probably not installed in the correct way.
I think this should be raised as a VIT, since it means those 3 datasets won't run until this is fixed.
@smancini @pblain