IBM Streams version 4.2.1 is now available, and includes enhanced Python support to make creating streaming applications in Python much easier.  For example, if you have existing Python classes and callables, you can now use them as operators in a Streams application. The Python API has also been improved to support monitoring and testing Python streaming applications.

In addition to the Python related enhancements, the user interfaces have been translated into major European, South American, and Asian languages.

This post gives an overview of some of the highlights of the release.

Enhanced Python support

User interface translation

Enhanced Python support

IBM Streams Processing Language (SPL) Python operator enhancements

You can use existing Python code in a Streams application by using the new decorators in the API.   The decorators allow you to create SPL primitive operators from Python callable classes or functions. Then, you can invoke those operators in an SPL application. Use these decorators to define stateful SPL operators with parameters:

  • @spl.source – Creates an SPL operator with a single output port.
  • @spl.filter – Creates an SPL operator with an input port and one or two output ports.
  • – Creates an SPL operator with a single input port and single output port.
  • @spl.for_each – Creates an SPL operator with a single input port.The following example demonstrates creating a ContainsFilter operator from a Python class.  The operator filters out tuples that do not contain the value of the parameter term in any of its attributes.
    < @spl.filter()
    class ContainsFilter:
    """ Looks for a string term in any attribute in the tuple."""
        def __init__(self, term):
            self.term = term
        def __call__(self, **tuple):
             for s in tuple.values():
                  if self.term in str(s):
                      return True
             return False

    This operator can be invoked in SPL as:

    // SP contains any tuple from S that has an attribute containing “unicorn”
    stream<S> SP = ContainsFilter(S) {
              term: “unicorn”;

SPL Python primitive operators now have access to the information about their runtime execution context, including creating metrics for application monitoring.

For more information, see the API documentation.

Additional Python API improvements

You can use this functional API to create and run an IBM Streams application by using only Python. The following capabilities are added to the API with this release:

  • Use SPL operators in a  Python application.
  • Develop applications by using Python 2.7.
  • Create metrics from Python.
  • Create Python tests for your Streaming applications by using the Python unittest module.
  • Use lambda expressions as stream transformations, for example, the following expression filters words that start with #stream:
    words.filter(lambda word : word.startswith('#stream'))



You can use the Python REST API to monitor IBM Streams instances, and running jobs; access the data from views on streams; and cancel submitted jobs. This API is a Python wrapper for the Streams REST API.

For example, the following Python REST API script determines how many jobs are running in an instance:

>>> sc = StreamsConnection() 
>>> inst = sc.get_instance(id=”StreamsInstance”)
>>> total, running = 0, 0 
>>> for job in inst.get_jobs():
 . . . total += 1 
 . . . if job.status == “running”:
 . . . running += 1 
>>> print(“There are “, total, “ jobs, “, running, “ of which are running.”) 

There are 5 jobs, 3 of which are running.

Read more about the Python REST API.

How to get the latest Python support

The Python APIs are shipped with IBM Streams, and are also available for download:

  • Get the latest version of the toolkit from the streamsx.topology project on GitHub. The v1.6 toolkit is shipped with IBM Streams.
  • Get the latest streamsx Python module from PyPi or install it with pip.

For more information about IBM Streams support for Python, see the Python API developer guide and the API documenation.

User interface translation

Streams Console and Streams Studio can now be displayed in any of the following languages: Brazilian Portuguese, French, German, Italian, Japanese, Korean, Russian, Simplified Chinese, Spanish, and Traditional Chinese. Learn more.  The Streams for Excel add-in has also been translated.

Learn more

Try Streams V4.2.1. today by downloading the Quick Start Edition.
Follow the Python API developer guide to learn more about the new Python features.

Join The Discussion