pyshacl/validate.py
def _run_pre_inference(
        cls, target_graph: GraphLike, inference_option: str, logger: Optional[logging.Logger] = None
    ):
        """
        Note, this is the OWL/RDFS pre-inference,
        it is not the Advanced Spec SHACL-Rule inferencing step.
        :param target_graph:
        :type target_graph: rdflib.Graph|rdflib.ConjunctiveGraph|rdflib.Dataset
        :param inference_option:
        :type inference_option: str
        :return:
        :rtype: NoneType
        """
        # Lazy import owlrl
        import owlrl

        from .inference import CustomRDFSOWLRLSemantics, CustomRDFSSemantics

        if logger is None:
            logger = logging.getLogger(__name__)
        try:
            if inference_option == 'rdfs':
                inferencer = owlrl.DeductiveClosure(CustomRDFSSemantics)
            elif inference_option == 'owlrl':
                inferencer = owlrl.DeductiveClosure(owlrl.OWLRL_Semantics)
            elif inference_option == 'both' or inference_option == 'all' or inference_option == 'rdfsowlrl':
                inferencer = owlrl.DeductiveClosure(CustomRDFSOWLRLSemantics)
            else:
                raise ReportableRuntimeError("Don't know how to do '{}' type inferencing.".format(inference_option))
        except Exception as e:  # pragma: no cover
            logger.error("Error during creation of OWL-RL Deductive Closure")
            if isinstance(e, ReportableRuntimeError):
                raise e
            raise ReportableRuntimeError(
                "Error during creation of OWL-RL Deductive Closure\n{}".format(str(e.args[0]))
            )
        if isinstance(target_graph, (rdflib.Dataset, rdflib.ConjunctiveGraph)):
            named_graphs = [
                rdflib.Graph(target_graph.store, i, namespace_manager=target_graph.namespace_manager)
                if not isinstance(i, rdflib.Graph)
                else i
                for i in target_graph.store.contexts(None)
            ]
        else:
            named_graphs = [target_graph]
        try:
            for g in named_graphs:
                inferencer.expand(g)
        except Exception as e:  # pragma: no cover
            logger.error("Error while running OWL-RL Deductive Closure")
            raise ReportableRuntimeError("Error while running OWL-RL Deductive Closure\n{}".format(str(e.args[0])))

        Note, this is the OWL/RDFS pre-inference,
        it is not the Advanced Spec SHACL-Rule inferencing step.
        :param target_graph:
        :type target_graph: rdflib.Graph|rdflib.ConjunctiveGraph|rdflib.Dataset
        :param inference_option:
        :type inference_option: str
        :return:
        :rtype: NoneType
        
Note, this is the OWL/RDFS pre-inference,
it is not the Advanced Spec SHACL-Rule inferencing step.
Note this is the OWL / RDFS pre - inference it is not the Advanced Spec SHACL - Rule inferencing step .
def _run_pre_inference(
        cls, target_graph: GraphLike, inference_option: str, logger: Optional[logging.Logger] = None
    ):
        import owlrl
        from .inference import CustomRDFSOWLRLSemantics, CustomRDFSSemantics
        if logger is None:
            logger = logging.getLogger(__name__)
        try:
            if inference_option == 'rdfs':
                inferencer = owlrl.DeductiveClosure(CustomRDFSSemantics)
            elif inference_option == 'owlrl':
                inferencer = owlrl.DeductiveClosure(owlrl.OWLRL_Semantics)
            elif inference_option == 'both' or inference_option == 'all' or inference_option == 'rdfsowlrl':
                inferencer = owlrl.DeductiveClosure(CustomRDFSOWLRLSemantics)
            else:
                raise ReportableRuntimeError("Don't know how to do '{}' type inferencing.".format(inference_option))
        except Exception as e:  
            logger.error("Error during creation of OWL-RL Deductive Closure")
            if isinstance(e, ReportableRuntimeError):
                raise e
            raise ReportableRuntimeError(
                "Error during creation of OWL-RL Deductive Closure\n{}".format(str(e.args[0]))
            )
        if isinstance(target_graph, (rdflib.Dataset, rdflib.ConjunctiveGraph)):
            named_graphs = [
                rdflib.Graph(target_graph.store, i, namespace_manager=target_graph.namespace_manager)
                if not isinstance(i, rdflib.Graph)
                else i
                for i in target_graph.store.contexts(None)
            ]
        else:
            named_graphs = [target_graph]
        try:
            for g in named_graphs:
                inferencer.expand(g)
        except Exception as e:  
            logger.error("Error while running OWL-RL Deductive Closure")
            raise ReportableRuntimeError("Error while running OWL-RL Deductive Closure\n{}".format(str(e.args[0])))
def _run_pre_inference ( cls , target_graph : GraphLike , inference_option : str , logger : Optional [ logging . Logger ] = None ) : import owlrl from . inference import CustomRDFSOWLRLSemantics , CustomRDFSSemantics if logger is None : logger = logging . getLogger ( __name__ ) try : if inference_option == 'rdfs' : inferencer = owlrl . DeductiveClosure ( CustomRDFSSemantics ) elif inference_option == 'owlrl' : inferencer = owlrl . DeductiveClosure ( owlrl . OWLRL_Semantics ) elif inference_option == 'both' or inference_option == 'all' or inference_option == 'rdfsowlrl' : inferencer = owlrl . DeductiveClosure ( CustomRDFSOWLRLSemantics ) else : raise ReportableRuntimeError ( "Don't know how to do '{}' type inferencing." . format ( inference_option ) ) except Exception as e : logger . error ( "Error during creation of OWL-RL Deductive Closure" ) if isinstance ( e , ReportableRuntimeError ) : raise e raise ReportableRuntimeError ( "Error during creation of OWL-RL Deductive Closure\n{}" . format ( str ( e . args [ 0 ] ) ) ) if isinstance ( target_graph , ( rdflib . Dataset , rdflib . ConjunctiveGraph ) ) : named_graphs = [ rdflib . Graph ( target_graph . store , i , namespace_manager = target_graph . namespace_manager ) if not isinstance ( i , rdflib . Graph ) else i for i in target_graph . store . contexts ( None ) ] else : named_graphs = [ target_graph ] try : for g in named_graphs : inferencer . expand ( g ) except Exception as e : logger . error ( "Error while running OWL-RL Deductive Closure" ) raise ReportableRuntimeError ( "Error while running OWL-RL Deductive Closure\n{}" . format ( str ( e . args [ 0 ] ) ) )
Note, this is the OWL/RDFS pre-inference,
it is not the Advanced Spec SHACL-Rule inferencing step.
Note this is the OWL / RDFS pre - inference it is not the Advanced Spec SHACL - Rule inferencing step .
"""
        Note, this is the OWL/RDFS pre-inference,
        it is not the Advanced Spec SHACL-Rule inferencing step.
        :param target_graph:
        :type target_graph: rdflib.Graph|rdflib.ConjunctiveGraph|rdflib.Dataset
        :param inference_option:
        :type inference_option: str
        :return:
        :rtype: NoneType
        """ # Lazy import owlrl # pragma: no cover # pragma: no cover
None
NoneType
cls
target_graph
GraphLike
None
inference_option
str
None
logger
Optional[logging.Logger]