comparison service/reasoning/oneShot @ 1414:1a277dba4cdc

oneShot can send to a dev instance Ignore-this: 37dfe0f67c01c221b861d2b3e3900051 darcs-hash:85955653cb2158901ccdc4bd204c78a2b0cf54c2
author drewp <drewp@bigasterisk.com>
date Wed, 24 Jul 2019 01:03:21 -0700
parents d8acab2b01f5
children c8562ace4917
comparison
equal deleted inserted replaced
1413:14802ffc9e44 1414:1a277dba4cdc
1 #!/usr/bin/python 1 #!/usr/bin/python
2 """ 2 """
3 send a statement to the reasoning server for one update cycle. Args 3 send a statement to the reasoning server for one update cycle. Args
4 are s/p/o in n3 notation, with many prefixes predefined here. 4 are s/p/o in n3 notation, with many prefixes predefined here.
5 """ 5 """
6 import sys, requests, time 6 import sys, requests, time, os
7 s, p, o = sys.argv[1:] 7 s, p, o = sys.argv[1:]
8 8
9 prefixes = { 9 prefixes = {
10 '': 'http://projects.bigasterisk.com/room/', 10 '': 'http://projects.bigasterisk.com/room/',
11 'room' : 'http://projects.bigasterisk.com/room/', 11 'room' : 'http://projects.bigasterisk.com/room/',
24 stmt = '%s %s %s .' % (expand(s), expand(p), expand(o)) 24 stmt = '%s %s %s .' % (expand(s), expand(p), expand(o))
25 print "Sending: %s" % stmt 25 print "Sending: %s" % stmt
26 26
27 t1 = time.time() 27 t1 = time.time()
28 ret = requests.post( 28 ret = requests.post(
29 'http://bang:9071/oneShot', 29 'http://%s/oneShot' % os.environ.get('REASONING', 'bang:9071'),
30 headers={"content-type": "text/n3"}, 30 headers={"content-type": "text/n3"},
31 data=stmt.encode('ascii')) 31 data=stmt.encode('ascii'))
32 g = float(ret.headers['x-graph-ms']) 32 g = float(ret.headers['x-graph-ms'])
33 print "%.1f ms for graph update; %.1f ms other overhead" % (g, 1000 * (time.time() - t1) - g) 33 print "%.1f ms for graph update; %.1f ms other overhead" % (g, 1000 * (time.time() - t1) - g)