Skip to content

kg_validation_utils

check_kg_executability(kg)

Checks if the given KG is executable as an ML pipeline, based on a pre-defined SHACL shape graph

Parameters:

Name Type Description Default
kg rdflib.Graph or str

object or path of graph to check

required
Source code in exe_kg_lib/utils/kg_validation_utils.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
def check_kg_executability(kg: Union[rdflib.Graph, str]) -> None:
    """Checks if the given KG is executable as an ML pipeline, based on a pre-defined SHACL shape graph

    Args:
        kg (rdflib.Graph or str): object or path of graph to check
    """
    r = validate(data_graph=kg, shacl_graph=SHACL_SHAPE_GRAPH_PATH)
    conforms, _, results_text = r
    if not conforms:
        print(results_text)
        print(
            "Validation of KG failed. To ensure executability of the KG as an ML pipeline, please fix the above error(s) and try again."
        )
        exit(1)
    return

Last update: October 20, 2023