concept quality control in category data

This is an excerpt from Manning's book The Art of Data Usability.
Even if I referred to quality controls as a test you design, it’s not a simple test of yes or no; it’s a way to gauge the quality level for comparisons. It leads to a yes or no answer when you ask yourself if you have the desired level of quality. The quality control for the size of a dataset is not does the dataset have size, it’s what is the size of the dataset? The latter allows you to examine the size after implementing a change.
Figure 7.2. Move quality controls that should be monitored post-project into maintenance
![]()
The dry run flag, is a boolean flag so that if we execute our command and provide the flag as an option (evaluating it as True) we won’t run the quality control as a Nagios plugin (returning the appropriate return code and printing out the corresponding message). Instead, when we run in dry run mode, we’ll only print out the count of validation errors and exit successfully.
Listing 12.7. completeness/qualitycontrol.py
import subprocess import os.path import click @click.command() @click.option('--critical', '-c', type=int) @click.option('--warning', '-w', type=int) @click.option('--reference', '-r', type=click.Path(exists=True)) @click.option('--schema', '-s', type=click.Path(exists=True)) @click.argument('descriptor', type=click.Path(exists=True)) def qualitycontrol(critical, warning, reference, schema, descriptor): filedir = os.path.dirname(__file__) checks = ( #1 ("python", os.path.join(filedir, "check_metadata_completeness.py"), "-s", schema, "-d", descriptor), ("python", os.path.join(filedir, "check_data_completeness.py"), "-r", reference, "-d", descriptor), ) error_count = sum([int(subprocess.check_output(check)) #2 for check in checks]) if error_count >= critical: print('CRITICAL: Completeness ({count} errors found)'.format( count=error_count)) raise SystemExit(2) if error_count >= warning: print('WARNING: Completeness ({count} errors found)'.format( count=error_count)) raise SystemExit(1) print('OK: Completeness') raise SystemExit(0) if __name__ == '__main__': try: qualitycontrol() except Exception as e: print('UNKNOWN: {0}'.format(e)) raise SystemExit(3) #1 List of quality controls to run #2 Run the quality controls and sum the error count from them