Validators¶
Schema validation for SSSOM files.
sssom.validators
¶
Validators.
SSSOMValidationError
¶
Bases: ValidationError
Raised when a mapping set fails validation.
All problems are available in :attr:results, with one problem per JSON path, so that a value
that JSON Schema validation reports twice counts once. The string representation lists at
most :data:MAX_REPORTED_PROBLEMS of them, so that tracebacks stay readable.
Source code in src/sssom/validators.py
__init__(results)
¶
Instantiate the error from the validation results that caused it.
validate(msdf, validation_types=None, fail_on_error=True)
¶
Validate SSSOM files against sssom-schema using linkML's validator function.
All requested validation types are run before anything is raised, so that the problems found
by all of them are reported together. Nothing is logged; use :func:print_linkml_report or
:func:format_validation_results to show the returned reports.
:param msdf: MappingSetDataFrame.
:param validation_types: SchemaValidationType
:param fail_on_error: If true, raise an error when any validation type reports problems with
a severity in :data:FAILING_SEVERITIES
:returns: A dictionary from validation types to validation reports
:raises SSSOMValidationError: If fail_on_error is true and any validation type reports
problems with a severity in :data:FAILING_SEVERITIES.
Source code in src/sssom/validators.py
get_failing_results(reports)
¶
Collect the results that make a mapping set fail validation.
:param reports: Validation reports.
:returns: The results with a severity in :data:FAILING_SEVERITIES, in report order.
Source code in src/sssom/validators.py
format_validation_results(results, limit=None)
¶
Format validation results as a human-readable list of problems.
:param results: The validation results to format. :param limit: The maximum number of problems to list, or None to list all of them.
:returns: A summary line followed by one line per problem.
Source code in src/sssom/validators.py
print_linkml_report(report, fail_on_error=True)
¶
Print the error messages in the report. Optionally throw exception.
:param report: A LinkML validation report
:param fail_on_error: if true, the function will throw an SSSOMValidationError exception when
there are results with a severity in :data:FAILING_SEVERITIES, listing them in its
message. Otherwise, the problems are logged.
:raises SSSOMValidationError: If fail_on_error is true and the report has results with a
severity in :data:FAILING_SEVERITIES.
Source code in src/sssom/validators.py
validate_json_schema(msdf, fail_on_error=True)
¶
Validate JSON Schema using linkml's JsonSchemaDataValidator.
:param msdf: MappingSetDataFrame to eb validated. :param fail_on_error: if true, the function will throw an ValidationError exception when there are errors
Source code in src/sssom/validators.py
validate_shacl(msdf, fail_on_error=True)
¶
Validate SCHACL file.
:param msdf: TODO: https://github.com/linkml/linkml/issues/850 . :param fail_on_error: if true, the function will throw an ValidationError exception when there are errors
:raises NotImplementedError: Not yet implemented.
Source code in src/sssom/validators.py
validate_sparql(msdf, fail_on_error=True)
¶
Validate SPARQL file.
:param msdf: MappingSetDataFrame :param fail_on_error: if true, the function will throw an ValidationError exception when there are errors
:raises NotImplementedError: Not yet implemented.
Source code in src/sssom/validators.py
check_all_prefixes_in_curie_map(msdf, fail_on_error=True)
¶
Check all EntityReference slots are mentioned in 'curie_map'.
:param msdf: MappingSetDataFrame :param fail_on_error: if true, the function will throw an ValidationError exception when there are errors
:raises ValidationError: If all prefixes not in curie_map.
Source code in src/sssom/validators.py
check_strict_curie_format(msdf, fail_on_error=True)
¶
Check all EntityReference slots are formatted as unambiguous curies.
Implemented rules:
- CURIE does not contain pipe "|" character to ensure that multivalued processing of in TSV works correctly.
:param msdf: MappingSetDataFrame :param fail_on_error: if true, the function will throw an ValidationError exception when there are errors
:raises ValidationError: If any entity reference does not follow the strict CURIE format