Mercurial > code > home > repos > homeauto
diff service/mqtt_to_rdf/inference/infer_perf_test.py @ 1727:23e6154e6c11
file moves
author | drewp@bigasterisk.com |
---|---|
date | Tue, 20 Jun 2023 23:26:24 -0700 |
parents | service/mqtt_to_rdf/infer_perf_test.py@0d7635335616 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/service/mqtt_to_rdf/inference/infer_perf_test.py Tue Jun 20 23:26:24 2023 -0700 @@ -0,0 +1,57 @@ +import logging +import unittest +from typing import cast + +from rdflib.graph import ConjunctiveGraph + +from inference.inference import Inference +from inference.inference_test import N3 +from inference.rdflib_debug_patches import patchBnodeCounter, patchSlimReprs + +patchSlimReprs() +patchBnodeCounter(always=False) + +logging.basicConfig(level=logging.DEBUG) + +# ~/.venvs/mqtt_to_rdf/bin/nosetests --with-watcher --logging-level=INFO --with-timer -s --nologcapture infer_perf_test + + +class TestPerf(unittest.TestCase): + + def test(self): + config = ConjunctiveGraph() + config.parse('conf/rules.n3', format='n3') + + inference = Inference() + inference.setRules(config) + expandedConfig = inference.infer(config) + expandedConfig += inference.nonRuleStatements() + print(cast(bytes, expandedConfig.serialize(format='n3')).decode('utf8')) + self.fail() + + for loop in range(50): + # g = N3(''' + # <urn:uuid:2f5bbe1e-177f-11ec-9f97-8a12f6515350> a :MqttMessage ; + # :body "online" ; + # :onlineTerm :Online ; + # :topic ( "frontdoorlock" "status") . + # ''') + # derived = inference.infer(g) + + # g = N3(''' + # <urn:uuid:2f5bbe1e-177f-11ec-9f97-8a12f6515350> a :MqttMessage ; + # :body "zz" ; + # :bodyFloat 12.2; + # :onlineTerm :Online ; + # :topic ( "air_quality_outdoor" "sensor" "bme280_temperature" "state") . + # ''') + # derived = inference.infer(g) + g = N3(''' + <urn:uuid:a4778502-1784-11ec-a323-464f081581c1> a :MqttMessage ; + :body "65021" ; + :bodyFloat 6.5021e+04 ; + :topic ( "air_quality_indoor" "sensor" "ccs811_total_volatile_organic_compound" "state" ) . + ''') + derived = inference.infer(g) + + # self.fail()