Mercurial > code > home > repos > homeauto
diff service/mqtt_to_rdf/inference.py @ 1661:00a5624d1d14
cleanups and optimizations
author | drewp@bigasterisk.com |
---|---|
date | Sun, 19 Sep 2021 16:51:51 -0700 |
parents | d8e5b2232474 |
children | 1a7c1261302c |
line wrap: on
line diff
--- a/service/mqtt_to_rdf/inference.py Sun Sep 19 15:39:37 2021 -0700 +++ b/service/mqtt_to_rdf/inference.py Sun Sep 19 16:51:51 2021 -0700 @@ -48,7 +48,6 @@ lhsChunk: Chunk prev: Optional['ChunkLooper'] workingSet: 'ChunkedGraph' - parent: 'Lhs' # just for lhs.graph, really def __repr__(self): return f'{self.__class__.__name__}{self._shortId}{"<pastEnd>" if self.pastEnd() else ""}' @@ -61,7 +60,8 @@ self._pastEnd = False self._seenBindings: List[CandidateBinding] = [] - log.debug(f'{INDENT*6} introducing {self!r}({self.lhsChunk}, {self._myWorkingSetMatches=})') + if log.isEnabledFor(logging.DEBUG): + log.debug(f'{INDENT*6} introducing {self!r}({self.lhsChunk}, {self._myWorkingSetMatches=})') self.restart() @@ -124,7 +124,7 @@ log.debug(f'{INDENT*6} advanceWithFunctions {pred}') for functionType in functionsFor(pred): - fn = functionType(self.lhsChunk, self.parent.graph) + fn = functionType(self.lhsChunk) log.debug(f'{INDENT*7} ChunkLooper{self._shortId} advanceWithFunctions, {functionType=}') try: @@ -263,7 +263,10 @@ for s in perm: try: - elem = ChunkLooper(s, prev, knownTrue, parent=self) + # These are getting rebuilt a lot which takes time. It would + # be nice if they could accept a changing `prev` order + # (which might already be ok). + elem = ChunkLooper(s, prev, knownTrue) except NoOptions: log.debug(f'{INDENT*6} permutation didnt work, try another') break