Developing IBM Streams applications with Python

You can use the IBM® Streams Python API to develop streaming applications that will run on the Streams instance.

Before you begin

Follow these steps to set up your development environment.
Tip: The Streams Python API is open source. For the latest information about how to set up for development, see IBM Streams Python setup.
  1. Install Python V3.6 and Java V8 or later.
  2. Set the JAVA_HOME environment variable to a Java 1.8 JRE or JDK/SDK.
  3. Install the Streams Python API by using pip:
    pip install streamsx
  4. Because the Streams instance is on a different host, you must set the following environment variables:
    • STREAMS_BUILD_URL: The Streams build service URL, for example, when the service is exposed as a node port: https://192.0.2.10:8534
    • STREAMS_REST_URL - The Streams SWS service (REST API) URL, for example, when the service is exposed as node port: https://192.0.2.10:8534
    • (Optional) STREAMS_USERNAME: The name of the user who submits the job. The default is the current operating system user name.
    • STREAMS_PASSWORD: The user password for authentication.
    For information about determining the build service or REST URL, see Accessing IBM Streams resources with REST and JMX APIs.

About this task

You can use the Streams Python API to develop streaming applications that will run on the Streams instance. Python applications can be developed using Jupyter notebooks or any text editor. A Streams Python application is also called a topology. You use the Python API to define the Topology and submit the Topology for execution.

When you run the Python code either from a notebook or from your local machine, the Streams application does not run locally. Rather, the topology you defined is submitted to the Streams instance where it will be compiled and executed.

Procedure

After you set the environment variables, you can run a sample application to get started.

  • If you have Jupyter notebooks installed locally you can use the Streams rolling average sample notebook from GitHub. This notebook walks you through creating a sample application that computes a rolling average on a simulated stream of data.
  • Follow the instructions in the Python development guide to create your first application by using the Python interpreter.

What to do next

After the application is running, you can view the job status, logs, and more from the Streams console.

To log in to the Streams console, you can use the same username and password that you used to submit the job.

You can also monitor an application programmatically by using the Streams REST APIs. For more information about using the REST APIs, see Monitoring and managing IBM Streams with REST and JMX APIs.