diff service/mqtt_to_rdf/inference.py @ 1638:0ba1625037ae

don't crash, just skip the rule if there's a BindingConflict (no clear test case yet)
author drewp@bigasterisk.com
date Mon, 13 Sep 2021 01:53:32 -0700
parents ec3f98d0c1d8
children ae5ca4ba8954
line wrap: on
line diff
--- a/service/mqtt_to_rdf/inference.py	Mon Sep 13 01:36:06 2021 -0700
+++ b/service/mqtt_to_rdf/inference.py	Mon Sep 13 01:53:32 2021 -0700
@@ -14,7 +14,7 @@
 from rdflib.graph import ConjunctiveGraph, ReadOnlyGraphAggregate
 from rdflib.term import Node, Variable
 
-from candidate_binding import CandidateBinding
+from candidate_binding import BindingConflict, CandidateBinding
 from inference_types import BindingUnknown, ReadOnlyWorkingSet, Triple
 from lhs_evaluation import functionsFor, lhsStmtsUsedByFuncs
 
@@ -339,7 +339,10 @@
                 key = tuple(sorted(bound.binding.binding.items())), b
                 self.rhsBnodeMap.setdefault(key, BNode())
 
-                bound.binding.addNewBindings(CandidateBinding({b: self.rhsBnodeMap[key]}))
+                try:
+                    bound.binding.addNewBindings(CandidateBinding({b: self.rhsBnodeMap[key]}))
+                except BindingConflict:
+                    continue
 
             # for lhsBoundStmt in bound.binding.apply(bound.lhsStmtsWithoutEvals()):
             #     log.debug(f'{INDENT*6} adding to workingSet {lhsBoundStmt=}')