Running A Wallaroo Python Application
Setting Up Wallaroo
You should have already completed the setup instructions in the "Setting Up Your Environment for Wallaroo" section of this guide.
Running the Application
Wallaroo uses an embedded Python runtime wrapped with a C API around it that lets Wallaroo execute Python code and read Python variables. So when
machida --application-module my_application is run,
machida (the binary we previously compiled), loads up the
my_application.py module inside of its embedded Python runtime and executes its
application_setup() function to retrieve the application topology it needs to construct in order to run the application.
Generally, in order to build a Wallaroo Python application, the following steps should be followed:
- Build the machida binary (this only needs to be done once)
import wallarooin the Python application's
- Create classes that provide the correct Wallaroo Python interfaces (more on this later)
- Define an
application_setupfunction that uses the
wallaroomodule to construct the application topology.
machidawith the application module as the
Once loaded, Wallaroo executes
application_setup(), constructs the appropriate topology, and enters a
ready state where it awaits incoming data to process.
A Note About PYTHONPATH
Machida uses the
PYTHONPATH environment variable to find modules that are imported by the application. You will have at least two modules in your
PYTHONPATH: the application module and the
wallaroo module. For example, if you have followed the directions for setting up the tutorial then the Wallaroo Python module is in
$HOME/wallaroo-tutorial/wallaroo-0.5.3/machida/wallaroo.py and the "Celsius to Fahrenheit" application module is in
$HOME/wallaroo-tutorial/wallaroo-0.5.3/examples/python/celsius/celsius.py, so you would export
PYTHONPATH like this:
If you are working your way through the tutorial you might find it easier to set up
PYTHONPATH to use whatever directory you are in as the search path so that you can run the application that is the current directory. To do this, you would export
PYTHONPATH like this:
If you chose to do this while working through the tutorial, you might also find it useful to add the path to the
machida executable to your
PATH, which can be done like this:
To learn how to write your own Wallaroo Python application, continue to Writing Your Own Application
To find out more detail on the command line arguments and other aspects of running Wallaroo application, see the Running Wallaroo section.