Python Operator API overview

You use the Teracloud® Streams Python Operator API to implement user-defined operators in Python.

The doxygen documentation for this API is provided with the Teracloud® Streams installation in the $STREAMS_INSTALL/doc/spl/operator/api/python/api directory. The package within this API is streams. Here is a brief description of its main classes.

  • streams.Operator: The base class and interface used to define an operator. The Teracloud Streams run time calls methods on this interface for initialization and then on for each incoming tuple and punctuation until a shutdown request is made. This is an alias to streams.Python.PythonOperator.

  • streams.OperatorContext: This interface provides access to the operator's runtime context, including descriptions of the streams and parameters.
  • streams.ProcessingElement: This interface provides access to the Processing Element, including information such as output and data directories.

There is also a python declaration module in the $STREAMS_INSTAL/doc/spl/operator/api/typings. In VSCode, you can add in settings.json the following entries to get auto completion (where you need to expand $STREAMS_INSTAL to the streams installation path)

    "python.autoComplete.extraPaths": [
        "$STREAMS_INSTAL/doc/spl/operator/api/typings"
    ],
    "python.analysis.extraPaths": [
        "$STREAMS_INSTAL/doc/spl/operator/api/typings"
    ],
Note: The python declaration module is only for editor assistance/documentation purposes only. During runtime, the streams api module is injected as a C module.

The Teracloud® Streams uses the Python version returned by python3-config. The python runtime that is linked to the application depends on the value that python3-config returns when the compiler (sc) is run.