In [1]:
import rsplib as rsp

In [2]:
e = rsp.Experiment()
qname = "Q1"
experimentName = "/experiment1.json"

e.add_engine('http://cqels.westeurope.cloudapp.azure.com', 80, rsp.Dialects.CQELS)

q = e.add_query(qname, "query", rsp.Dialects.CQELS)
q.set_select_clause("?obId1 ?obId2 ?v1 ?v2")
q.set_where_clause("?p1   a <http://www.insight-centre.org/citytraffic#CongestionLevel>.?p2   a <http://www.insight-centre.org/citytraffic#CongestionLevel>.")
e.add_stream(qname,"AarhusTrafficData182955", "http://triplewave1.westeurope.cloudapp.azure.com:4000/sgraph").add_window('3s','1s').add_bgp("{?obId1 a ?ob.?obId1 <http://purl.oclc.org/NET/ssnx/ssn#observedProperty> ?p1.?obId1 <http://purl.oclc.org/NET/sao/hasValue> ?v1.?obId1 <http://purl.oclc.org/NET/ssnx/ssn#observedBy> <http://www.insight-centre.org/dataset/SampleEventService#AarhusTrafficData182955>.}")
e.add_stream(qname,"AarhusTrafficData158505", "http://triplewave1.westeurope.cloudapp.azure.com:4001/sgraph").add_window('3s','1s').add_bgp("{?obId2 a ?ob.?obId2 <http://purl.oclc.org/NET/ssnx/ssn#observedProperty> ?p2.?obId2 <http://purl.oclc.org/NET/sao/hasValue> ?v2.?obId2 <http://purl.oclc.org/NET/ssnx/ssn#observedBy> <http://www.insight-centre.org/dataset/SampleEventService#AarhusTrafficData158505>.}")

#e.add_windowed_stream(qname,"AarhusTrafficData182955", "http://triplewave1.westeurope.cloudapp.azure.com:4000/sgraph", '3s','1s' )
#e.add_windowed_stream(qname,"AarhusTrafficData158505", "http://triplewave1.westeurope.cloudapp.azure.com:4000/sgraph", '3s','1s' )

#e.add_graph(qname, "SensorRepository", "https://rsplab.blob.core.windows.net/static/SensorRepository.rdf", serialization="RDF/XML", default='true')
#e.add_graph(qname, "AarhusLibraryEvents", "https://rsplab.blob.core.windows.net/static/AarhusLibraryEvents.rdf", serialization="RDF/XML", default='true')


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-3d71195b321c> in <module>()
      8 q.set_select_clause("?obId1 ?obId2 ?v1 ?v2")
      9 q.set_where_clause("?p1   a <http://www.insight-centre.org/citytraffic#CongestionLevel>.?p2   a <http://www.insight-centre.org/citytraffic#CongestionLevel>.")
---> 10 e.add_stream(qname,"AarhusTrafficData182955", "http://triplewave1.westeurope.cloudapp.azure.com:4000/sgraph").add_window('3s','1s').add_bgp("{?obId1 a ?ob.?obId1 <http://purl.oclc.org/NET/ssnx/ssn#observedProperty> ?p1.?obId1 <http://purl.oclc.org/NET/sao/hasValue> ?v1.?obId1 <http://purl.oclc.org/NET/ssnx/ssn#observedBy> <http://www.insight-centre.org/dataset/SampleEventService#AarhusTrafficData182955>.}")
     11 e.add_stream(qname,"AarhusTrafficData158505", "http://triplewave1.westeurope.cloudapp.azure.com:4001/sgraph").add_window('3s','1s').add_bgp("{?obId2 a ?ob.?obId2 <http://purl.oclc.org/NET/ssnx/ssn#observedProperty> ?p2.?obId2 <http://purl.oclc.org/NET/sao/hasValue> ?v2.?obId2 <http://purl.oclc.org/NET/ssnx/ssn#observedBy> <http://www.insight-centre.org/dataset/SampleEventService#AarhusTrafficData158505>.}")
     12 

AttributeError: 'NoneType' object has no attribute 'add_bgp'

In [10]:
q.streams[0].location


Out[10]:
'http://triplewave1.westeurope.cloudapp.azure.com:4000/sgraph'

In [ ]:


In [3]:
import json

base_dir = "./experiment_cqels"
def jdefault(o):
        return o.__dict__()
    
with open(base_dir+experimentName, "w") as myfile:
    myfile.write(json.dumps(e, default=jdefault, indent=4, sort_keys=True))

In [4]:
rsp.execute(e)


{"name":"cqels","host":"cqels/","runUUID":"6b9ddebe-2776-11e7-85a8-000d3a2755dc","port":8182,"empty_results":false,"inference":false,"timestam_function":false,"backloop":true,"num_streams":0,"num_datasets":0,"num_queries":0}
Registering stream: AarhusTrafficData182955
"Stream AarhusTrafficData182955 succesfully registered with IRI http://triplewave1.westeurope.cloudapp.azure.com:4000/sgraph"
Registering stream: AarhusTrafficData158505
"Stream AarhusTrafficData158505 succesfully registered with IRI http://triplewave1.westeurope.cloudapp.azure.com:4000/sgraph"
Registering query Q1 
"Query name specified in the uri must be equals to the name contained in the query body"
Query name specified in the uri must be equals to the name contained in the query body
Registering observers for Q1
"Q1 ID is not associated to any registered query"
"Q1 ID is not associated to any registered query"
[]
Out[4]:
<rsplib.ExperimentExecution at 0x7f22edc00630>

In [ ]: