<jupyter_start><jupyter_text>Creating a Simple ApplicationThe Streams Python API allows a user to create a streams application using only python. The Python API allows for the definition of data sources, transformations, and sinks by performing operations on `Stream` and `Topology` objects.First, it is necessary to import the `Topology` class from the `streamsx.topology` package. This will be used to begin create your application. In addition, the `context` module must be imported, allowing your application to be submitted.Lastly, import the classes of the operators you wish to use. Here we use `Counter`, a source operator which counts from 0 to infinity, and `negative_one`, an operator which returns the negative of every number it is given<jupyter_code>from streamsx.topology.topology import Topology
from streamsx.topology import context
from my_module import Counter, negative_one<jupyter_output><empty_output><jupyter_text>The Topology ObjectA Topology object is a container for the structure of your application. Give it a unique name, otherwise it may overwrite other compiled streams applications.<jupyter_code>top = Topology("myTop")<jupyter_output><empty_output><jupyter_text>Define and Create Your Data SourceBy creating an instance of the `Counter` operator, we can use it as a data source by invoking the `source` method on your `Topology` object and passing it the `my_counter` object. The output of a source is a `Stream` which represents the flow of data in your applications. A streams consists of a potentially infinite sequence of Python object upon which you can perform subsequent operations (such as multiplying by negative one)<jupyter_code># Define source
my_counter = Counter()
stream_1 = top.source(my_counter)<jupyter_output><empty_output><jupyter_text>Performing Operations On Your Data StreamA user might want to perform a number of operations on a stream of live data; for example, extracting sentiment from tweets, keeping track of a GPS device, or monitoring live traffic data. All of these operations take data items of one type and modify them or produce data of another type. With the Python API, this can be achieved by calling `map` on a Stream and passing it an operator.As mentioned before, `negative_one` is a callable class which takes a number, and returns its negative.<jupyter_code># multiple by negative one
neg_one = negative_one()
stream_2 = stream_1.map(neg_one)

# Print stream
stream_2.print()<jupyter_output><empty_output><jupyter_text>SubmissionSubmit the application to be run locally in a single process. The output will be sent to standard output and printed to the screen.<jupyter_code>out = context.submit("STANDALONE", top.graph)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup