In this article we introduce Python EPL plug-in. How to invoke the Python code from within Apama EPL. We demonstrate how to call Python code from EPL using sample code snippet that returns the reverse of a string from Python program

Introduction :

Now Customer can execute the machine Learning code developed in Python scripts as part of their Apama applications to make use use of Streaming analytics

A Python EPL plug-in allows developers to call Python code in an EPL application. The Python EPL plug-in will execute the python file.
Current EPL plug-in supports Python 3.6.6

Prerequisite :

Install Apama and Designer from Software AG Installer. Python 3 comes with the installation of Apama

EPL In Action:

Following EPL and Python code snippet demonstrates how to call Python from EPL.

Python program from apama.eplplugin should import EPLAction, EPLPluginBase. Python class should have a constructor. For example:

from apama.eplplugin import EPLAction, EPLPluginBase

Sample Python Code :

class TestPluginClass(EPLPluginBase):

   def __init__(self,init):
        self.getLogger().info("TestPluginClass initialised")

Member functions that can be accessed by EPL needs to be declared with signature. For example:


   @EPLAction("action<string> returns string ")
    def reverse(self,s):
        rev = ""
        for i in s:
            rev = i + rev
        return rev

In the CorrelatorConfig.yaml file, user needs to configure the plug-ins:

    pythonFile: "${PARENT_DIR}/../plugins/"
    class: TestPluginClass

Sample Apama Code :

package apamax.testpluginsample;

monitor TestPluginMonitor {

    import "TestPlugin" as plugin;

    action onload()
        string originalstr := "malayalam";
        string rev := plugin.reverse(originalstr);
        log "Reverse of the string is: " + rev at INFO;



Apama Project folder structure exhibiting the CorrelatorConfig.yaml, TestPlugin.mon inside the monitor and inside plugins folder

Conclusion :

In this article, we just demonstrated how to use Python EPL plug-in. User can create a complex Python application using NumPy, SciPy, Pandas, Matplotlib,Keras, TensorFlow etc and make use of these in Apama directly.

Please see the attachement section for working python and Apama mon. (810 Bytes)

SimplePlugin.mon (671 Bytes)