Skip to content
Madhawa Vidanapathirana edited this page Sep 1, 2017 · 14 revisions

Welcome to PySiddhi wiki.

Siddhi is a Query Language and a Library developed by WSO2 Inc. for Real-time Complex Events Processing. Siddhi CEP Library is currently used in WSO2 Data Analytics Server, an Enterprise Grade Open Source Data Analytics Solution.

The Siddhi CEP Library is originally written in Java 8.0. PySiddhi is a Python wrapper on Siddhi CEP Java Library.

The following versions of Siddhi CEP is covered by this Python wrapper.

  • Siddhi CEP 3.1.0 (Released Version) is wrapped by PySiddhi3.
  • Siddhi CEP 4.0.0-M53 (In Development Version) is wrapped by PySiddhi4.

PySiddhi4 includes a REST Client on WSO2 Data Analytics Server 4.0.0-M6.

Note: PySiddhi API is initiated by a project for Google Summer of Code 2017 Program.

Content

Quick Demo

The following is a demo code on PySiddhi3. For a demo on PySiddhi4, refer this link.

Step 1 - Define your query using Siddhi.

define stream cseEventStream (symbol string, price float, volume long);
@info(name = 'query1') from cseEventStream[volume < 150] select symbol,price insert into outputStream;

For more details on Siddhi Query Language, refer Siddhi Query Language Guide in WSO2 Docs.

Step 2 - Feed input events using Input Handler.

inputHandler.send(["IBM",700.0,LongType(100)])
inputHandler.send(["WSO2", 60.5, LongType(200)])
...

Step 3 - Receive callbacks on output events.

class QueryCallbackImpl(QueryCallback):
    def receive(self, timestamp, inEvent, outEvent):
        PrintEvent(timestamp, inEvents, outEvents)
executionPlanRuntime.addCallback("query1",ConcreteQueryCallback())

Receive Outputs

INFO  EventPrinter - Events{ @timestamp = 1497708406678, inEvents = [Event{timestamp=1497708406678, id=-1, data=[IBM, 700.0], isExpired=false}], RemoveEvents = null }
...

Refer Full Quick Demo for complete code on above example.

Installation

PySiddhi can be installed as a Python Library from Source Code. No binary releases are available as of now.

Refer Installation Guide for installation prerequisites and other details. Using the following PIP commands, it is possible to directly install PySiddhi API from online GitHub Repository.

Installing PySiddhi4

pip install git+https://github.com/wso2/PySiddhi.git

Installing PySiddhi3

pip install git+https://github.com/wso2/[email protected]