event stream processing promo
SAS Analytics for IoT running SAS Event Stream Processing on desktop monitor

SAS ESPPy Library
for developers

Getting started with SAS ESPPy

The ESPPy package enables you to create SAS Event Stream Processing (ESP) models programmatically in Python. Using ESPPy, you can connect to an ESP server and interact with projects and their components as Python objects.

 Features:

  • full integration with Jupyter notebooks
  • visualize diagrams of your ESP projects
  • support for streaming charts and images
  • easily embed an ESP project inside a Python pipeline

Try ESPPy for free!

  • explore the capabilities of SAS Event Stream Processing
  • self-contained programming environment - no installation
  • use JupyterLab as an interface
  • run Python code and work through pre-packaged examples

Sample code

The sample code below establishes a connection and loads a project. To see further sample code, visit the ESPPy examples page on GitHub.

Create a new ESP project


# Import the ESPPy package and create a connection

In [1] : import esppy
         esppy.ESP?
         esp = esppy.ESP('http://esp-server.com:8610')
         esp
Out[2] : ESP('http://esp-server.com:8610')

# Load a project
In [3] : %%sh
         cat model_walking.xml
<engine>
  <projects>
    <project name='project' pubsub='auto' threads='1' use-tagged-token='true'>
      <contqueries>
        <contquery name='contquery' trace='w_data w_calculate'>
          <windows>
            <window-source name='w_data' insert-only='true'>
              <schema>
                <fields>
                  <field name='id'   type='int64' key='true'/>
                  <field name='time' type='double'/>
                  <field name='x'    type='double'/>
                  <field name='y'    type='double'/>
                  <field name='z'    type='double'/>
                </fields>
              </schema>
            </window-source>
            <window-source name='w_request' insert-only='true'>
              <schema>
                <fields>
                  <field name='req_id'  type='int64' key='true'/>
                  <field name='req_key' type='string'/>
                  <field name='req_val' type='string'/>
                </fields>
              </schema>
            </window-source>
            <window-calculate name='w_calculate' algorithm='Summary'>
              <schema>
                <fields>
                  <field name='id'     type='int64' key='true'/>
                  <field name='x'      type='double'/>
                  <field name='mean_x' type='double'/>
                  <field name='n_x'    type='int64'/>
                </fields>
              </schema>
              <parameters>
                <properties>
                  <property name="windowLength">5</property>
                </properties>
              </parameters>
              <input-map>
                <properties>
                  <property name="input">x</property>
                </properties>
              </input-map>
              <output-map>
                <properties>
                  <property name="meanOut">mean_x</property>
                  <property name="nOut">n_x</property>
                </properties>
              </output-map>
            </window-calculate>
            <window-copy name="w_copy"/>
          </windows>
          <edges>
            <edge source='w_data'    target='w_calculate' role='data'/>
            <edge source='w_request' target='w_calculate' role='request'/>
            <edge source='w_calculate'    target='w_copy' role='data'/>
          </edges>
        </contquery>
      </contqueries>
    </project>
  </projects>
</engine>

Back to Top