!pip install rsplib --upgrade

from rsplib.processing import execute, deploy
from rsplib.processing.consumer.query import *
from rsplib.experiments import Experiment, ExperimentExecution, Report

"""
Explanation: ISWC 2017 RSP Demo
Ensure you have the latest version of rsplib
End of explanation
"""


#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' )

"""
Explanation: A simple Experiment Using CITYBENCH Streams
End of explanation
"""


ex = deploy(e)

"""
Explanation: 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
End of explanation
"""


execute(ex)

"""
Explanation: Execute, i.e. unregister streams, queries and observers to the output streams after a fixed amount of time
End of explanation
"""


ex.__dict__()

"""
Explanation: Experiment Recap
End of explanation
"""


