Mercurial > code > home > repos > homeauto
comparison service/mqtt_to_rdf/inference.py @ 1603:7f8bf68534ed
logging and stats
author | drewp@bigasterisk.com |
---|---|
date | Mon, 06 Sep 2021 00:56:47 -0700 |
parents | e3c44ac6d3c5 |
children | 449746d1598f |
comparison
equal
deleted
inserted
replaced
1602:e3c44ac6d3c5 | 1603:7f8bf68534ed |
---|---|
84 | 84 |
85 newBindings, usedGraph = ev.resultBindings(self.binding) | 85 newBindings, usedGraph = ev.resultBindings(self.binding) |
86 usedByFuncs += usedGraph | 86 usedByFuncs += usedGraph |
87 self._addNewBindings(newBindings) | 87 self._addNewBindings(newBindings) |
88 delta = len(self.binding) - before | 88 delta = len(self.binding) - before |
89 dump = "(...)" | 89 if log.isEnabledFor(logging.DEBUG): |
90 if log.isEnabledFor(logging.DEBUG) and cast(int, usedGraph.__len__()) < 20: | 90 dump = "(...)" |
91 dump = graphDump(usedGraph) | 91 if cast(int, usedGraph.__len__()) < 20: |
92 log.debug(f'{INDENT*4} rule {dump} made {delta} new bindings') | 92 dump = graphDump(usedGraph) |
93 log.debug(f'{INDENT*4} rule {dump} made {delta} new bindings') | |
93 return delta | 94 return delta |
94 | 95 |
95 def _addNewBindings(self, newBindings): | 96 def _addNewBindings(self, newBindings): |
96 for k, v in newBindings.items(): | 97 for k, v in newBindings.items(): |
97 if k in self.binding and self.binding[k] != v: | 98 if k in self.binding and self.binding[k] != v: |
158 | 159 |
159 def findCandidateBindings(self, workingSet: ReadOnlyWorkingSet) -> Iterator[CandidateBinding]: | 160 def findCandidateBindings(self, workingSet: ReadOnlyWorkingSet) -> Iterator[CandidateBinding]: |
160 """bindings that fit the LHS of a rule, using statements from workingSet and functions | 161 """bindings that fit the LHS of a rule, using statements from workingSet and functions |
161 from LHS""" | 162 from LHS""" |
162 log.debug(f'{INDENT*3} nodesToBind: {self.lhsBindables}') | 163 log.debug(f'{INDENT*3} nodesToBind: {self.lhsBindables}') |
164 self.stats['findCandidateBindingsCalls'] += 1 | |
163 | 165 |
164 if not self._allStaticStatementsMatch(workingSet): | 166 if not self._allStaticStatementsMatch(workingSet): |
167 self.stats['findCandidateBindingEarlyExits'] += 1 | |
165 return | 168 return |
166 | 169 |
167 candidateTermMatches: Dict[BindableTerm, Set[Node]] = self._allCandidateTermMatches(workingSet) | 170 candidateTermMatches: Dict[BindableTerm, Set[Node]] = self._allCandidateTermMatches(workingSet) |
168 | 171 |
169 orderedVars, orderedValueSets = _organize(candidateTermMatches) | 172 orderedVars, orderedValueSets = _organize(candidateTermMatches) |