ISWC 2017 RSP Demo

Ensure you have the latest version of rsplib


In [ ]:
!pip install rsplib --upgrade

In [38]:
from rsplib.processing import execute, deploy
from rsplib.processing.consumer.query import *
from rsplib.experiments import Experiment, ExperimentExecution, Report

A simple Experiment Using CITYBENCH Streams


In [42]:
#create the experiment
e = Experiment()
#number of time the experiment is reapeated
repetition=1

#set the experiment duration
e.set_duration(30,'s')

#Add an engine, in this case C-SPARQL engine, and specify which RSP dialect it speaks
e.add_engine('csparql', 8182, Dialects.CSPARQL)

#Add a query, using the programmatic API. No worries about different syntax
#rsplib takes care of using the right one, just specify the dialect

qname = "Demo"
# Name, Type, Dialect
q = e.add_query(qname, "stream", Dialects.CSPARQL)
q.set_select_clause("{?s ?p ?o}")
q.set_where_clause("?s ?p ?o")
e.add_windowed_stream(qname,"AarhusTrafficData182955", "http://aarhustrafficdata182955:4000/sgraph", '3s','1s' )
e.add_windowed_stream(qname,"AarhusTrafficData158505", "http://aarhustrafficdata158505:4001/sgraph", '3s','1s' )


Out[42]:
<rsplib.experiments.Experiment at 0x7f55ee85bef0>

Deploy The Experiment, i.e. register streams, queries and observers to the output streams

Go And Check CSPARQL performance at http://localhost:3000/dashboard/db/csparql login admin pw admin


In [43]:
ex = deploy(e)


{"name":"csparql","host":"csparql/","runUUID":"37488a19-bd87-11e7-812c-1a00a83a5601","port":8182,"empty_results":false,"inference":false,"timestam_function":false,"backloop":false,"num_streams":0,"num_datasets":0,"num_queries":0}
Registering stream: AarhusTrafficData182955
"Stream AarhusTrafficData182955 succesfully registered with IRI http://aarhustrafficdata182955:4000/sgraph"
Registering stream: AarhusTrafficData158505
"Stream AarhusTrafficData158505 succesfully registered with IRI http://aarhustrafficdata158505:4001/sgraph"
Registering query Demo 
{'queryBody': 'REGISTER STREAM Demo AS CONSTRUCT {?s ?p ?o} FROM STREAM <AarhusTrafficData182955> [RANGE 3s STEP 1s]\n FROM STREAM <AarhusTrafficData158505> [RANGE 3s STEP 1s]\nWHERE {?s ?p ?o\n}'}
"Query Demo succesfully registered"
Query Demo succesfully registered
Registering observers for Demo
"http://csparql:8182/queries/Demo/observers/default"
{ "@context": {"sld":"http://streamreasoning.org/ontologies/SLD4TripleWave#","generatedAt": {"@id":"http://www.w3.org/ns/prov#generatedAtTime","@type":"http://www.w3.org/2001/XMLSchema#dateTime"}},"@id": "default","@type": "sld:sGraph","sld:streamLocation": "ws://csparql:9101/Demo/results"}
[{"id":"Demo","type":"STREAM","status":"RUNNING"}]

Execute, i.e. unregister streams, queries and observers to the output streams after a fixed amount of time


In [44]:
execute(ex)


[{"id":"Demo","type":"STREAM","status":"RUNNING"}]
[{"id":"default","url":"ws://csparql:9101/Demo/results"}]
"Observer default (ws://csparql:9101/Demo) succesfully unregistered"
"Query Demo and stream csparql/queries/Demo succesfully unregistered"
[{"streamURL":"AarhusTrafficData158505","status":"RUNNING"},{"streamURL":"AarhusTrafficData182955","status":"RUNNING"}]
"Stream AarhusTrafficData158505 succesfully unregistered"
"Stream AarhusTrafficData182955 succesfully unregistered"

Experiment Recap


In [46]:
ex.__dict__()


Out[46]:
{'Execution': {'D': [],
  'E': {'backloop': False,
   'empty_results': False,
   'host': 'csparql/',
   'inference': False,
   'name': 'csparql',
   'num_datasets': 0,
   'num_queries': 0,
   'num_streams': 0,
   'port': 8182,
   'runUUID': '37488a19-bd87-11e7-812c-1a00a83a5601',
   'timestam_function': False},
  'K': None,
  'O': [{'Demo': {'@context': {'generatedAt': {'@id': 'http://www.w3.org/ns/prov#generatedAtTime',
       '@type': 'http://www.w3.org/2001/XMLSchema#dateTime'},
      'sld': 'http://streamreasoning.org/ontologies/SLD4TripleWave#'},
     '@id': 'default',
     '@type': 'sld:sGraph',
     'sld:streamLocation': 'ws://csparql:9101/Demo/results'}}],
  'Q': [{'id': 'Demo', 'status': 'RUNNING', 'type': 'STREAM'}],
  'R': None,
  'S': ['Stream AarhusTrafficData182955 succesfully registered with IRI http://aarhustrafficdata182955:4000/sgraph',
   'Stream AarhusTrafficData158505 succesfully registered with IRI http://aarhustrafficdata158505:4001/sgraph'],
  'end_time': '2017-10-30 15:44:49',
  'start_time': '2017-10-30 15:44:19'},
 'Experiment': {'duration': {'time': 30, 'unit': 's'},
  'engine': {'dialect': 'CSPARQL', 'host': 'csparql', 'port': 8182},
  'graphs': [],
  'metadata': {},
  'queries': [{'name': 'Demo', 'body': 'CONSTRUCT {?s ?p ?o} FROM STREAM <AarhusTrafficData182955> [RANGE 3s STEP 1s]\n FROM STREAM <AarhusTrafficData158505> [RANGE 3s STEP 1s]\nWHERE {?s ?p ?o\n}', 'type': 'stream', 'dialect': 'CSPARQL', 'structure': {'select_clause': '{?s ?p ?o}', 'where_clause': {'default': ['?s ?p ?o'], 'named': [], 'unnamed': []}, 'streams': [{'name': 'AarhusTrafficData182955', 'location': 'http://aarhustrafficdata182955:4000/sgraph', 'scale_factor': 1, 'window': {'range': '3s', 'step': '1s'}}, {'name': 'AarhusTrafficData158505', 'location': 'http://aarhustrafficdata158505:4001/sgraph', 'scale_factor': 1, 'window': {'range': '3s', 'step': '1s'}}], 'group_by': '', 'having': '', 'order_by': ''}}],
  'streams': [{'name': 'AarhusTrafficData182955', 'location': 'http://aarhustrafficdata182955:4000/sgraph', 'scale_factor': 1, 'window': {'range': '3s', 'step': '1s'}},
   {'name': 'AarhusTrafficData158505', 'location': 'http://aarhustrafficdata158505:4001/sgraph', 'scale_factor': 1, 'window': {'range': '3s', 'step': '1s'}}]}}

End