comparison 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
comparison
equal deleted inserted replaced
1726:7d3797ed6681 1727:23e6154e6c11
1 import logging
2 import unittest
3 from typing import cast
4
5 from rdflib.graph import ConjunctiveGraph
6
7 from inference.inference import Inference
8 from inference.inference_test import N3
9 from inference.rdflib_debug_patches import patchBnodeCounter, patchSlimReprs
10
11 patchSlimReprs()
12 patchBnodeCounter(always=False)
13
14 logging.basicConfig(level=logging.DEBUG)
15
16 # ~/.venvs/mqtt_to_rdf/bin/nosetests --with-watcher --logging-level=INFO --with-timer -s --nologcapture infer_perf_test
17
18
19 class TestPerf(unittest.TestCase):
20
21 def test(self):
22 config = ConjunctiveGraph()
23 config.parse('conf/rules.n3', format='n3')
24
25 inference = Inference()
26 inference.setRules(config)
27 expandedConfig = inference.infer(config)
28 expandedConfig += inference.nonRuleStatements()
29 print(cast(bytes, expandedConfig.serialize(format='n3')).decode('utf8'))
30 self.fail()
31
32 for loop in range(50):
33 # g = N3('''
34 # <urn:uuid:2f5bbe1e-177f-11ec-9f97-8a12f6515350> a :MqttMessage ;
35 # :body "online" ;
36 # :onlineTerm :Online ;
37 # :topic ( "frontdoorlock" "status") .
38 # ''')
39 # derived = inference.infer(g)
40
41 # g = N3('''
42 # <urn:uuid:2f5bbe1e-177f-11ec-9f97-8a12f6515350> a :MqttMessage ;
43 # :body "zz" ;
44 # :bodyFloat 12.2;
45 # :onlineTerm :Online ;
46 # :topic ( "air_quality_outdoor" "sensor" "bme280_temperature" "state") .
47 # ''')
48 # derived = inference.infer(g)
49 g = N3('''
50 <urn:uuid:a4778502-1784-11ec-a323-464f081581c1> a :MqttMessage ;
51 :body "65021" ;
52 :bodyFloat 6.5021e+04 ;
53 :topic ( "air_quality_indoor" "sensor" "ccs811_total_volatile_organic_compound" "state" ) .
54 ''')
55 derived = inference.infer(g)
56
57 # self.fail()